What is the primary intent of the Composite Design Pattern?
To ensure a class has only one instance.
To treat individual objects and compositions of objects uniformly.
To provide a way to access the elements of an aggregate object sequentially.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
Which of the following is a key characteristic of a Proxy object in the Proxy Pattern?
It provides an identical interface to the real subject object.
It cannot modify the behavior of the real subject object.
It must implement a different interface than the real subject object.
It always has direct access to the real subject object.
How does the Prototype Pattern contribute to code flexibility?
It allows you to define new object types at runtime.
It simplifies the process of unit testing.
It eliminates the need for inheritance.
It promotes loose coupling by reducing dependencies between classes.
Which of these relationships best describes the Composite pattern?
Inheritance
Association
Realization
Both Inheritance and Composition
How does the Composite pattern promote code reusability?
By encapsulating object creation logic.
By allowing objects to change their behavior at runtime.
By providing a common interface for interacting with simple and complex objects.
By ensuring that a class has only one instance.
Which of these scenarios best exemplifies the use of the Prototype Pattern?
Logging user actions in a system.
Implementing undo/redo functionality in a text editor.
Creating multiple instances of game characters with slightly varying attributes.
Managing the state of a traffic light system.
How does the Builder Pattern differ from using telescoping constructors?
The Builder Pattern provides better control and clarity when building objects with many attributes.
Telescoping constructors are preferred when the object construction is complex.
The Builder Pattern is less flexible when dealing with optional attributes.
Telescoping constructors are more readable for a large number of attributes.
What type of Proxy is used to control access to a resource based on access rights?
Caching Proxy
Virtual Proxy
Remote Proxy
Protection Proxy
How does the State Pattern typically handle state transitions?
A separate 'State Manager' class controls all transitions.
State transitions are determined by external events only.
State objects have methods to trigger transitions to other states.
The 'Context' object directly modifies its internal state.
What is the primary purpose of the Proxy Pattern in software design?
To provide a simplified interface to a complex subsystem.
To control access to an object, potentially restricting its use.
To allow objects to be notified of changes in other objects.
To define a family of algorithms and encapsulate each one.