Quick Answer
Decorator pattern adds behavior to an object dynamically without modifying its class or using inheritance. Wrap the original object in a decorator that adds functionality and delegates to the original. Stackable - wrap multiple decorators. Java I/O streams are classic decorators: BufferedInputStream wraps FileInputStream, adding buffering. Enables open/closed principle - extend behavior without modifying existing code.
Answer
Adds behavior to objects dynamically without modifying class. Promotes composition over inheritance. Used in I/O streams and UI components.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.