Skip to content
Sharp

Design patterns · interview question

How does the Decorator pattern help align with the Open/Closed Principle?

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

Correct answer

B. By allowing extension without modification

Why

The Decorator pattern enables new functionalities by wrapping objects, allowing behavior extension without modifying existing code, thus adhering to the Open/Closed Principle.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →