All mock tests are FREE till 31 December — register to save your progress

A software design pattern used to enhance the functionality of an object at run-time is:

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. Decorator

Explanation

The Decorator pattern wraps an object in another object that implements the same interface and adds behaviour before or after forwarding the call, so responsibilities can be attached to an individual object dynamically at run time without subclassing. Adapter does not add functionality; it converts one interface into another so incompatible classes can work together. Proxy also keeps the same interface but controls access to the object (lazy loading, remote access, protection) rather than enhancing its behaviour. Delegation is a general object-oriented technique, not one of the GoF patterns. Hence Decorator.

More Programming Languages and Computer Graphics questions