← Quiz: Observer, Strategy and Decorator: all 10 questions
Quiz: Observer, Strategy and Decorator · Question 10 of 10
Decorator differs from inheritance because a decorator:
Decorator differs from inheritance because a decorator:
- A.Changes every object of the class at compile time
- B.Cannot call the wrapped object's methods
- C.Requires multiple inheritance
- D.Adds behaviour to one object at runtime, and decorators can be combined freely
Answer & explanation
Correct answer: Adds behaviour to one object at runtime, and decorators can be combined freely
Inheritance fixes behaviour per class at compile time; decorators are stacked per object.
Can you get the rest right without peeking?
Take the timed Quiz: Observer, Strategy and Decorator quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →