Skip to content
Sharp

Design patterns · interview question

How would you explain a key benefit of using the Decorator pattern over subclassing in an interview?

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

Correct answer

C. It supports dynamic behavior changes.

Why

The Decorator pattern supports adding new functionality at runtime, enabling dynamic behavior changes without altering existing class structures. This provides flexibility that subclassing cannot achieve.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →