Skip to content
Sharp

Design patterns · interview question

How would you explain a key advantage of using decorators over creating subclasses for each new behavior in an interview?

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

Correct answer

C. Reduces the need for multiple subclass permutations

Why

Decorators allow you to add behaviors without creating numerous subclasses, thus avoiding the complexity of managing a large class hierarchy with many permutations.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →