Skip to content
Sharp

Design patterns · interview question

Which of the following is an example of using the Decorator pattern in a checkout system?

Multiple choiceMediumchapter-13-curatedpremiumdesign-patternsdecorator-pattern
Choose one answer
Answer and explanation

Correct answer

D. Creating a wrap for items that applies a discount and calculates total

Why

The Decorator pattern involves wrapping objects to dynamically apply additional behaviors, such as discounts, without modifying the original item class.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →