Skip to content
Sharp

Object-oriented programming · interview question

Which principle is violated if class fields are accessed directly?

Multiple choiceEasychapter-3-curatedpremiumoopinvariants-and-validation
Choose one answer
Answer and explanation

Correct answer

D. Encapsulation

Why

Direct access to class fields violates encapsulation, as it exposes the internal state and breaks the control over data integrity.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →