Which of these is a common use case for the Observer pattern?
Implementing a notification system.
Implementing an undo/redo mechanism.
Creating a singleton object.
Defining a factory for creating objects.
Which principle of object-oriented design does the Adapter Pattern primarily promote?
Inheritance
Polymorphism
Encapsulation
Composition
Which object-oriented principle does the Factory Method pattern primarily promote?
Liskov Substitution Principle
Open/Closed Principle
Single Responsibility Principle
Dependency Inversion Principle
Which of these scenarios best illustrates the use of a Facade Pattern?
Creating multiple subclasses with specialized methods.
Providing a single, unified API to interact with a database system.
Iterating through a collection of objects without exposing its structure.
Defining a one-to-many dependency between objects.
What is a potential drawback of using the Factory Method pattern?
It prevents the use of dependency injection for object creation.
It is not suitable for creating objects from abstract interfaces.
It violates the Open/Closed Principle, making code harder to modify.
It can lead to increased code complexity, especially with many subclasses.
How does the Command Pattern achieve decoupling?
By relying on a central registry to map requests to their handlers.
By using inheritance to create specialized request handlers.
By introducing an intermediary object (the Command) between the invoker and the receiver.
By directly connecting the object making the request with the object fulfilling it.
Which of the following is NOT a typical category of design patterns?
Structural
Behavioral
Creational
Functional
In Java, what keyword is commonly used to ensure thread-safe Singleton instantiation?
volatile
abstract
synchronized
final
What is the primary intent of the Observer pattern?
To define a family of algorithms, encapsulate each one, and make them interchangeable.
To ensure a class has only one instance.
To provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Design patterns primarily target which aspect of software development?
Code structure and organization
Database optimization
Application security
Code compilation speed