Skip to content
Sharp

Object-oriented programming · interview question

How can a ShoppingCart notify a user when a product is out of stock?

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

Correct answer

D. By integrating a callback or observer pattern.

Why

Using a callback or observer pattern allows ShoppingCart to notify users asynchronously, promoting a decoupled and dynamic interaction design.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →