Skip to content
Sharp

Design patterns · interview question

In implementing a Decorator, why is it crucial to maintain the same interface as the original object?

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

Correct answer

B. To ensure compatibility with other decorators

Why

Maintaining the same interface ensures that decorators can be used interchangeably with the original object, preserving polymorphic behavior and allowing for seamless integration into existing systems.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →