Skip to content
Sharp

Object-oriented programming · interview question

What design flaw exists if a User class directly accesses ShoppingCart's internal list of items?

Multiple choiceHardchapter-2-curatedpremiumoopobject-interaction
Choose one answer
Answer and explanation

Correct answer

B. It breaks encapsulation and increases coupling.

Why

Directly accessing ShoppingCart's internal list breaks encapsulation and increases coupling, making code harder to maintain and less flexible to changes.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →