Skip to content
Sharp

Object-oriented programming · interview question

Which design principle is violated if a 'Product' class directly modifies a 'Customer' class's balance?

Multiple choiceHardchapter-2-curatedpremiumoopbasic-modeling
Choose one answer
Answer and explanation

Correct answer

D. Encapsulation

Why

Directly modifying another class's state violates encapsulation, as it breaks the control over how data is accessed and modified. Each class should manage its own state to maintain data integrity and separation of concerns.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →