Skip to content
Sharp

Object-oriented programming · interview question

In an e-commerce application, which class should likely contain the method to add an item to the shopping cart?

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

Correct answer

D. ShoppingCart

Why

The ShoppingCart class should manage its contents, including methods to add items. This keeps responsibilities clear and focused.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →