Skip to content
Sharp

Core Java · interview question

Why can having many public fields in a Java class become a bug in practice?

Multiple choiceEasychapter-2-curatedpremiumcore-javacode-reading-and-refactoring-to-objects
Choose one answer
Answer and explanation

Correct answer

A. It can lead to fragile code that is hard to maintain.

Why

Public fields expose internal data, reducing encapsulation and making the class more susceptible to errors when changes are made. It can lead to tight coupling, making maintenance and updates more challenging.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →