Which statement describes the Proxy pattern?

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

Which statement describes the Proxy pattern?

Explanation:
The Proxy pattern is about introducing a stand-in for another object to control access, delay expensive work, or add extra behavior around operations. A proxy sits in place of the real object and implements the same interface, so clients can use it transparently. This lets you defer creating the real object until it’s actually needed (lazy loading), enforce access control, or inject things like logging or caching without changing how the client talks to the object. The other descriptions point to different patterns: composing objects into trees for part-whole hierarchies is the Composite pattern; ensuring only one instance is the Singleton pattern; and adding behavior to an object without changing its interface is characteristic of the Decorator pattern. The Proxy’s key purpose is controlling access or deferring work, which is why this description is the best fit.

The Proxy pattern is about introducing a stand-in for another object to control access, delay expensive work, or add extra behavior around operations. A proxy sits in place of the real object and implements the same interface, so clients can use it transparently. This lets you defer creating the real object until it’s actually needed (lazy loading), enforce access control, or inject things like logging or caching without changing how the client talks to the object.

The other descriptions point to different patterns: composing objects into trees for part-whole hierarchies is the Composite pattern; ensuring only one instance is the Singleton pattern; and adding behavior to an object without changing its interface is characteristic of the Decorator pattern. The Proxy’s key purpose is controlling access or deferring work, which is why this description is the best fit.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy