What is the primary goal of the Flyweight pattern?
To minimize memory usage by sharing common data among multiple objects.
To provide a way to access shared objects in a synchronized manner.
To encapsulate algorithms in objects, allowing for easy swapping and extension.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
In a language like Java, how is object cloning often achieved within the Prototype Pattern?
By directly copying object properties.
By using the spread operator.
spread
By using the Object.assign() method.
Object.assign()
By implementing the Cloneable interface.
Cloneable
How does the Flyweight pattern contribute to object-oriented design principles?
It improves performance by reducing the number of objects instantiated.
It enhances code reusability by encapsulating common behavior in shared objects.
All of the above.
It promotes loose coupling by separating object creation from usage.
Which of these real-world scenarios could benefit from applying the Iterator Pattern?
Processing a stream of data from a sensor network.
Navigating through a playlist of songs in a music player.
Representing a menu structure in a graphical user interface.
In the State Pattern, what does the 'Context' class represent?
The interface or abstract class defining state-specific actions.
The mechanism for transitioning between states.
The class that holds the current state of the object.
The concrete classes implementing different states.
Which of these relationships best describes the Composite pattern?
Association
Both Inheritance and Composition
Inheritance
Realization
In the context of the Proxy Pattern, what does the term 'subject' refer to?
The interface shared by the proxy and the real object.
The object being accessed through the proxy.
The client that interacts with the proxy or the real object.
The object that controls access to the real object.
Which of these is NOT a common use case for the Prototype Pattern?
Maintaining a cache of frequently used objects for performance optimization.
Creating objects with complex initialization logic.
Building systems with dynamic object creation based on user input.
Implementing a factory method pattern.
How does the Iterator Pattern handle situations where the underlying collection might be modified during iteration?
It creates a copy of the collection to ensure data integrity during iteration.
It relies on the client code to manage synchronization and prevent issues.
It generally does not handle this directly; safeguards like concurrent modification exceptions might be needed.
It automatically prevents any modifications to the collection while iteration is in progress.
Which of these is NOT a common use case for the Flyweight pattern?
Representing and rendering a complex 3D model with shared textures.
Text editors handling character formatting.
Game development for managing large numbers of units or particles.
Implementing a logging system with different log levels.