Skip to content
Sharp

Object-oriented programming · interview question

How would you explain a consequence of not using encapsulation in Java classes in an interview?

Multiple choiceMediumchapter-3-curatedpremiumoopcontrolled-mutation
Choose one answer
Answer and explanation

Correct answer

D. Increased likelihood of bugs due to uncontrolled access

Why

Without encapsulation, fields can be modified from outside the class, leading to bugs and inconsistencies, as the internal state can be altered without any control or validation.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →