CS FundamentalsVery hardHCL · Accenture

An object wraps another object that implements the same interface, adding behaviour dynamically before or after delegating (as BufferedReader wraps a Reader). Which pattern is this?

  1. A. Adapter
  2. B. Singleton
  3. C. Observer
  4. D. Decorator

Correct answer: D. Decorator

A Decorator adds responsibilities to an object at run time by wrapping it behind the same interface.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic