Design Patterns and Best Practices

Test your knowledge on Design Patterns and Best Practices.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which design pattern is used to define a family of algorithms, encapsulate each one, and make them interchangeable?

  1. Factory Method
  2. Strategy
  3. Observer
  4. Singleton
Question 2 Multiple Choice (Single Answer)

What is the purpose of the Observer design pattern?

  1. To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  2. To create a single instance of a class and provide a global point of access to that instance.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 3 Multiple Choice (Single Answer)

Which design pattern is used to create a single instance of a class and provide a global point of access to that instance?

  1. Factory Method
  2. Strategy
  3. Observer
  4. Singleton
Question 4 Multiple Choice (Single Answer)

What is the purpose of the Factory Method design pattern?

  1. To define a family of algorithms, encapsulate each one, and make them interchangeable.
  2. To create a single instance of a class and provide a global point of access to that instance.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 5 Multiple Choice (Single Answer)

Which design pattern is used to provide a way to add or remove objects from a collection dynamically?

  1. Factory Method
  2. Strategy
  3. Observer
  4. Composite
Question 6 Multiple Choice (Single Answer)

What is the purpose of the Adapter design pattern?

  1. To convert the interface of a class into another interface clients expect.
  2. To define a family of algorithms, encapsulate each one, and make them interchangeable.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 7 Multiple Choice (Single Answer)

Which design pattern is used to define a family of related classes and provide a way to create objects without specifying their exact class?

  1. Factory Method
  2. Abstract Factory
  3. Builder
  4. Prototype
Question 8 Multiple Choice (Single Answer)

What is the purpose of the Builder design pattern?

  1. To define a family of related classes and provide a way to create objects without specifying their exact class.
  2. To convert the interface of a class into another interface clients expect.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 9 Multiple Choice (Single Answer)

Which design pattern is used to provide a way to create objects without specifying their exact class?

  1. Factory Method
  2. Abstract Factory
  3. Builder
  4. Prototype
Question 10 Multiple Choice (Single Answer)

What is the purpose of the Decorator design pattern?

  1. To attach additional responsibilities to an object dynamically.
  2. To convert the interface of a class into another interface clients expect.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 11 Multiple Choice (Single Answer)

Which design pattern is used to provide a way to undo or redo actions?

  1. Command
  2. Memento
  3. Observer
  4. Singleton
Question 12 Multiple Choice (Single Answer)

What is the purpose of the Memento design pattern?

  1. To provide a way to undo or redo actions.
  2. To convert the interface of a class into another interface clients expect.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 13 Multiple Choice (Single Answer)

Which design pattern is used to provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation?

  1. Iterator
  2. Composite
  3. Observer
  4. Singleton
Question 14 Multiple Choice (Single Answer)

What is the purpose of the Composite design pattern?

  1. To provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
  2. To convert the interface of a class into another interface clients expect.
  3. To provide a way to add or remove objects from a collection dynamically.
  4. To define an interface for creating objects, but let subclasses decide which class to instantiate.
Question 15 Multiple Choice (Single Answer)

Which design pattern is used to provide a way to define a family of related classes and create objects without specifying their exact class?

  1. Factory Method
  2. Abstract Factory
  3. Builder
  4. Prototype