Design Patterns and Best Practices
Test your knowledge on Design Patterns and Best Practices.
Questions
Which design pattern is used to define a family of algorithms, encapsulate each one, and make them interchangeable?
- Factory Method
- Strategy
- Observer
- Singleton
What is the purpose of the Observer design pattern?
- To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
- To create a single instance of a class and provide a global point of access to that instance.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to create a single instance of a class and provide a global point of access to that instance?
- Factory Method
- Strategy
- Observer
- Singleton
What is the purpose of the Factory Method design pattern?
- To define a family of algorithms, encapsulate each one, and make them interchangeable.
- To create a single instance of a class and provide a global point of access to that instance.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to provide a way to add or remove objects from a collection dynamically?
- Factory Method
- Strategy
- Observer
- Composite
What is the purpose of the Adapter design pattern?
- To convert the interface of a class into another interface clients expect.
- To define a family of algorithms, encapsulate each one, and make them interchangeable.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to define a family of related classes and provide a way to create objects without specifying their exact class?
- Factory Method
- Abstract Factory
- Builder
- Prototype
What is the purpose of the Builder design pattern?
- To define a family of related classes and provide a way to create objects without specifying their exact class.
- To convert the interface of a class into another interface clients expect.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to provide a way to create objects without specifying their exact class?
- Factory Method
- Abstract Factory
- Builder
- Prototype
What is the purpose of the Decorator design pattern?
- To attach additional responsibilities to an object dynamically.
- To convert the interface of a class into another interface clients expect.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to provide a way to undo or redo actions?
- Command
- Memento
- Observer
- Singleton
What is the purpose of the Memento design pattern?
- To provide a way to undo or redo actions.
- To convert the interface of a class into another interface clients expect.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation?
- Iterator
- Composite
- Observer
- Singleton
What is the purpose of the Composite design pattern?
- To provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
- To convert the interface of a class into another interface clients expect.
- To provide a way to add or remove objects from a collection dynamically.
- To define an interface for creating objects, but let subclasses decide which class to instantiate.
Which design pattern is used to provide a way to define a family of related classes and create objects without specifying their exact class?
- Factory Method
- Abstract Factory
- Builder
- Prototype