Skip to content
Sharp

Object-oriented programming · interview question

Why are public mutable fields risky in a store model?

Multiple choiceEasychapter-3-curatedpremiumoopencapsulation
Choose one answer
Answer and explanation

Correct answer

A. Any caller can push the object into invalid business state

Why

If outside code can assign any value directly, the object cannot defend its own rules. Encapsulation matters because it protects the truth of the model, not just because private fields look cleaner.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →