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

A software design pattern often used to restrict access to an object is:

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

Show answer & explanation

Correct answer: D. proxy

Explanation

The answer is proxy. A proxy provides a surrogate or placeholder that stands in for another object and controls access to it, which is exactly what a protection proxy, a virtual proxy or a remote proxy does. The adapter pattern converts one interface into another so that incompatible classes can work together, and the decorator pattern attaches extra responsibilities to an object at run time without changing its interface, so neither is about restricting access. Delegation is a general technique of forwarding a request to a helper object, not a GoF pattern for access control.

More Programming Languages and Computer Graphics questions