In the context of the Decorator Pattern, what is the relationship between the 'ConcreteComponent' and 'Decorator'?
The Decorator inherits from the ConcreteComponent.
There is no direct relationship between them.
Both the Decorator and ConcreteComponent implement the same interface.
The ConcreteComponent inherits from the Decorator.
What is the primary intent of the Strategy Pattern in software design?
To ensure that a class has only one instance and provides a global point of access to it.
To encapsulate data and behavior together in a single unit.
To provide a way to access elements of an aggregate object sequentially.
To define a family of algorithms and encapsulate each one for interchangeable use.
Which of these scenarios best illustrates a use case for the Singleton pattern?
Implementing a sorting algorithm for a list of numbers.
Managing a database connection pool for an application.
Displaying different product variations on an e-commerce site.
Creating multiple user accounts for a website.
What is a potential drawback of using the Factory Method pattern?
It is not suitable for creating objects from abstract interfaces.
It can lead to increased code complexity, especially with many subclasses.
It violates the Open/Closed Principle, making code harder to modify.
It prevents the use of dependency injection for object creation.
Which of the following is a potential drawback of the Singleton pattern?
It promotes code reusability.
It makes unit testing more challenging.
It reduces the need for global variables.
It simplifies dependency injection.
In a Singleton class, the constructor is typically declared as:
static
private
protected
public
How does the Factory Method pattern typically handle the instantiation of concrete objects?
Subclasses override the factory method to provide their own creation logic.
It uses a chain of conditional statements within the factory method.
It delegates the instantiation to separate builder classes.
It relies on dependency injection to provide concrete object instances.
Which of these is NOT a core component of the Strategy Pattern?
Strategy
Context
Factory
ConcreteStrategy
What is the main difference between Object Adapter and Class Adapter?
Object Adapter is suitable for adapting concrete classes, while Class Adapter is for interfaces.
Object Adapter uses inheritance, while Class Adapter uses composition.
Class Adapter uses inheritance, while Object Adapter uses composition.
There is no difference, both are implemented the same way.
How does the Decorator Pattern differ from traditional inheritance for extending functionality?
Inheritance allows for dynamic extension at runtime, while Decorator does not.
Decorator provides more flexibility by allowing the combination of multiple functionalities at runtime.
Inheritance is generally preferred over Decorator due to its simplicity.
Decorator modifies the original class, while inheritance creates new subclasses.