Skip to content
Sharp

Object-oriented programming · interview question

In an e-commerce system, how can encapsulation help manage complex interactions between 'CartItem' objects?

Multiple choiceHardchapter-3-curatedpremiumoopaccess-modifiers-and-visibility
Choose one answer
Answer and explanation

Correct answer

C. By providing well-defined methods for interaction.

Why

Encapsulation allows a 'CartItem' to manage its internal state and behavior through well-defined methods. This approach ensures complex interactions are handled safely and predictably, maintaining 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 →