Skip to content
Sharp

Design patterns · interview question

Which design pattern allows adding responsibilities to objects dynamically at runtime?

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

Correct answer

C. Decorator

Why

The Decorator pattern allows you to add new functionality to an object dynamically by wrapping it in a new class. This is useful when you want to add responsibilities without modifying existing code.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →