Design Patterns

Description: Design Patterns Quiz
Number of Questions: 15
Created by:
Tags: design patterns software engineering
Attempted 0/15 Correct 0 Score 0

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

  1. Strategy

  2. Factory

  3. Singleton

  4. Decorator


Correct Option: A
Explanation:

The Strategy design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. This allows the algorithm to be selected at runtime.

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

  1. Singleton

  2. Factory

  3. Builder

  4. Prototype


Correct Option: A
Explanation:

The Singleton design pattern is used to create a single instance of a class and provide a global point of access to that instance.

Which design pattern is used to create objects without specifying the exact class of the object that will be created?

  1. Factory

  2. Builder

  3. Prototype

  4. Abstract Factory


Correct Option: A
Explanation:

The Factory design pattern is used to create objects without specifying the exact class of the object that will be created.

Which design pattern is used to create a new object by copying an existing object?

  1. Prototype

  2. Builder

  3. Factory

  4. Singleton


Correct Option: A
Explanation:

The Prototype design pattern is used to create a new object by copying an existing object.

Which design pattern is used to add new functionality to an existing object without changing its structure?

  1. Decorator

  2. Adapter

  3. Proxy

  4. Facade


Correct Option: A
Explanation:

The Decorator design pattern is used to add new functionality to an existing object without changing its structure.

Which design pattern is used to convert the interface of a class into another interface that a client expects?

  1. Adapter

  2. Decorator

  3. Proxy

  4. Facade


Correct Option: A
Explanation:

The Adapter design pattern is used to convert the interface of a class into another interface that a client expects.

Which design pattern is used to provide a unified interface to a set of interfaces in a subsystem?

  1. Facade

  2. Proxy

  3. Decorator

  4. Adapter


Correct Option: A
Explanation:

The Facade design pattern is used to provide a unified interface to a set of interfaces in a subsystem.

Which design pattern is used to define an interface for creating objects, but lets subclasses decide which class to instantiate?

  1. Abstract Factory

  2. Factory

  3. Builder

  4. Prototype


Correct Option: A
Explanation:

The Abstract Factory design pattern is used to define an interface for creating objects, but lets subclasses decide which class to instantiate.

Which design pattern is used to separate the construction of a complex object from its representation so that the same construction process can create different representations?

  1. Builder

  2. Factory

  3. Prototype

  4. Abstract Factory


Correct Option: A
Explanation:

The Builder design pattern is used to separate the construction of a complex object from its representation so that the same construction process can create different representations.

Which design pattern is used to define a set of classes that share a common interface, allowing objects to be composed dynamically?

  1. Composite

  2. Decorator

  3. Adapter

  4. Proxy


Correct Option: A
Explanation:

The Composite design pattern is used to define a set of classes that share a common interface, allowing objects to be composed dynamically.

Which design pattern is used to provide a surrogate or placeholder for another object to control access to it?

  1. Proxy

  2. Decorator

  3. Adapter

  4. Facade


Correct Option: A
Explanation:

The Proxy design pattern is used to provide a surrogate or placeholder for another object to control access to it.

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. Decorator

  4. Adapter


Correct Option: A
Explanation:

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

Which design pattern is used to define an object that encapsulates how a set of objects interact?

  1. Mediator

  2. Observer

  3. Command

  4. Strategy


Correct Option: A
Explanation:

The Mediator design pattern is used to define an object that encapsulates how a set of objects interact.

Which design pattern is used to define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically?

  1. Observer

  2. Mediator

  3. Command

  4. Strategy


Correct Option: A
Explanation:

The Observer design pattern is used to define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Which design pattern is used to encapsulate a request as an object, thereby allowing you to parameterize clients with different requests, queue or log requests, and undo requests?

  1. Command

  2. Observer

  3. Mediator

  4. Strategy


Correct Option: A
Explanation:

The Command design pattern is used to encapsulate a request as an object, thereby allowing you to parameterize clients with different requests, queue or log requests, and undo requests.

- Hide questions