In the context of the Factory Method pattern, what does the 'factory method' typically return?
A primitive data type, such as an integer or a string.
An instance of a specific concrete class.
A configuration object used to customize object creation.
An abstract interface or base class type.
Which of these scenarios best illustrates the use of a Facade Pattern?
Iterating through a collection of objects without exposing its structure.
Defining a one-to-many dependency between objects.
Creating multiple subclasses with specialized methods.
Providing a single, unified API to interact with a database system.
In the Observer pattern, what does the 'subject' object do?
Maintains a list of its dependents and notifies them of state changes.
Both B and C
Provides an interface for attaching and detaching observer objects.
Observes the state of other objects.
Which scenario best exemplifies a situation where the Command Pattern would be beneficial?
You have a simple algorithm that doesn't require encapsulation or extensibility.
You have a graphical user interface with buttons that trigger different actions on a document.
You need to represent a hierarchical relationship between objects.
You need to create objects of varying types based on user input.
What is a key characteristic of a well-implemented design pattern?
It is tightly coupled to a specific problem domain.
It eliminates the need for documentation.
It introduces significant code complexity.
It promotes code reusability and maintainability.
Which of the following real-world analogies best describes the Adapter Pattern?
A car factory producing different models of cars.
A restaurant menu listing available dishes and their prices.
A coffee machine using different types of coffee capsules.
A universal travel adapter allowing different plugs to fit into a socket.
What is the primary intent of the Factory Method pattern in software development?
To delegate object creation to subclasses, promoting extensibility.
To enforce strict object creation rules through a central factory class.
To create objects directly within a class, exposing instantiation logic.
To reduce code duplication by reusing object creation code across classes.
Which of these is a common real-world analogy used to explain the Decorator Pattern?
A tree structure representing hierarchical relationships.
A chain of objects processing a request sequentially.
A factory producing different types of objects.
Adding toppings to a base coffee or ice cream.
In a Singleton class, the constructor is typically declared as:
public
private
protected
static
In Python, a common way to implement a Singleton is by using:
Multiple inheritance
Decorators
Abstract classes
Interfaces