Skip to content
Sharp

Object-oriented programming · interview question

In the context of e-commerce, which class is most likely to contain a method called calculateTotalPrice()?

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

Correct answer

D. ShoppingCart

Why

The calculateTotalPrice() method would logically belong to the ShoppingCart class, as it needs to aggregate prices of multiple items in the cart.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →