Skip to content
Sharp

Design patterns · interview question

Which pattern would you choose to apply different pricing strategies without altering the client code?

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

Correct answer

D. Decorator

Why

The Decorator pattern is ideal for applying different pricing strategies dynamically. By wrapping the pricing objects, it allows for the addition of new pricing strategies without modifying client code.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →