1.
Which type/category has Abstract Factory Pattern?
Correct Answer
A. Creational
Explanation
The correct answer is Creational. The Abstract Factory Pattern is a creational design pattern that provides an interface for creating families of related or dependent objects without specifying their concrete classes. It allows the client code to create objects without knowing the specific class names, promoting loose coupling and flexibility in object creation.
2.
Which type/category has Factory Method Pattern?
Correct Answer
A. Creational
Explanation
The Factory Method Pattern belongs to the Creational type/category. This pattern is used to create objects without specifying the exact class of object that will be created. It provides an interface for creating objects, but allows subclasses to decide which class to instantiate. This promotes loose coupling and allows for flexibility in object creation.
3.
Which type/category has Prototype Pattern?
Correct Answer
A. Creational
Explanation
The Prototype Pattern belongs to the Creational category. This pattern is used to create objects by cloning or copying existing objects, rather than creating new instances from scratch. It allows for the creation of new objects with minimal overhead, as it avoids the need for complex initialization. Therefore, the Prototype Pattern falls under the Creational category, which focuses on object creation mechanisms.
4.
Which type/category has Singleton Pattern?
Correct Answer
A. Creational
Explanation
The Singleton Pattern belongs to the Creational category. This pattern is used to ensure that only one instance of a class is created and provides a global point of access to it. It is commonly used in scenarios where there should be a single instance of a class that needs to be shared across the entire application. The Creational category focuses on the creation of objects, and the Singleton Pattern specifically deals with the creation of a single instance of a class.
5.
Which type/category has Builder Pattern?
Correct Answer
A. Creational
Explanation
The Builder Pattern belongs to the Creational category. Creational design patterns focus on the creation of objects and provide ways to create objects in a manner that enhances flexibility and reusability. The Builder Pattern specifically separates the construction of complex objects from their representation, allowing the same construction process to create different representations. It is commonly used when there is a need to create different variations of an object while keeping the construction process consistent.
6.
Which type/category has Decorator Pattern?
Correct Answer
B. Structural
Explanation
The Decorator Pattern falls under the Structural category. This pattern allows the addition of new functionality to an object dynamically, by wrapping it within a decorator class. It provides a flexible alternative to subclassing for extending the behavior of an object, without changing its structure. The Structural category of design patterns focuses on the composition of classes and objects to form larger structures and provide more complex functionalities.
7.
Which type/category has Composite Pattern?
Correct Answer
B. Structural
Explanation
The Composite Pattern belongs to the Structural category. This pattern is used to compose objects into tree structures to represent part-whole hierarchies. It allows clients to treat individual objects and compositions of objects uniformly, making it easier to work with complex object structures. The Structural category focuses on the composition of classes and objects to form larger structures and relationships between them.
8.
Which type/category has Flyweight Pattern?
Correct Answer
B. Structural
Explanation
The Flyweight Pattern belongs to the Structural category. This pattern is used to minimize memory usage by sharing common data between multiple objects. It achieves this by separating intrinsic and extrinsic state, where intrinsic state is shared among multiple objects and extrinsic state can vary. This pattern is commonly used in situations where a large number of similar objects need to be created and memory optimization is crucial.
9.
Which type/category has Adapter Pattern?
Correct Answer
B. Structural
Explanation
The Adapter Pattern belongs to the Structural category. This pattern allows objects with incompatible interfaces to work together by creating a wrapper or adapter class that converts the interface of one object into another interface that the client expects. It helps to bridge the gap between different interfaces and promotes code reusability and flexibility.
10.
Which type/category has Bridge Pattern?
Correct Answer
B. Structural
Explanation
The Bridge Pattern belongs to the Structural category. The Bridge Pattern is used to decouple an abstraction from its implementation, allowing them to vary independently. It achieves this by creating a bridge between the abstraction and its implementation, enabling them to change and evolve separately. This pattern is commonly used when there is a need to switch or add different implementations of an abstraction without affecting the client code.
11.
Which type/category has Facade Pattern?
Correct Answer
B. Structural
Explanation
The Facade Pattern belongs to the Structural category. This pattern provides a simplified interface to a complex system of classes, acting as a unified interface to a set of interfaces in a subsystem. It allows clients to interact with the system in a simplified manner, hiding the complexities and dependencies of the subsystem behind a single facade class. Therefore, the Facade Pattern is categorized as a structural pattern that focuses on simplifying the structure of a system.
12.
Which type/category has Proxy Pattern?
Correct Answer
B. Structural
Explanation
The correct answer is "Structural" because the Proxy Pattern is a design pattern that falls under the structural category. The Proxy Pattern involves the use of a surrogate object, known as a proxy, that controls access to another object. This pattern is used to provide a level of indirection when accessing the original object, allowing for additional functionality to be added or restrictions to be imposed.
13.
Which type/category has Mediator Pattern?
Correct Answer
C. Behavioral
Explanation
The Mediator Pattern belongs to the Behavioral category. This pattern promotes loose coupling by encapsulating communication between objects and centralizing it in a mediator object. It allows objects to communicate with each other without having direct references to one another, thus reducing dependencies and making the system more flexible and maintainable.
14.
Which type/category has Visitor Pattern?
Correct Answer
C. Behavioral
Explanation
The Visitor Pattern is a behavioral design pattern. It is used to separate the algorithms from the objects on which they operate. This pattern allows new operations to be added to an object structure without modifying the objects themselves. The Visitor Pattern is commonly used when there are multiple unrelated operations that need to be performed on objects in a structure. Therefore, the correct answer is Behavioral.
15.
Which type/category has Template Method Pattern?
Correct Answer
C. Behavioral
Explanation
The Template Method Pattern is a behavioral design pattern. It defines the skeleton of an algorithm in a superclass but allows subclasses to override specific steps of the algorithm without changing its structure. This pattern is used to create a template or blueprint for a series of similar algorithms, promoting code reuse and providing a way to define the overall structure of an algorithm while allowing subclasses to implement the specific steps. Therefore, the correct answer is Behavioral.
16.
Which type/category has Iterator Pattern?
Correct Answer
C. Behavioral
Explanation
The Iterator Pattern falls under the Behavioral category. This pattern is used to provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. It allows the client to traverse the collection of objects without worrying about the specific implementation details. Therefore, it focuses on the behavior of objects and their interactions.
17.
Which type/category has Command Pattern?
Correct Answer
C. Behavioral
Explanation
The Command Pattern falls under the category of Behavioral design patterns. This pattern is used to encapsulate a request as an object, allowing clients to parameterize clients with queues, requests, and operations. It separates the sender of a request from the receiver, providing a way to parameterize clients with queues, requests, and operations. This pattern is commonly used to implement undo/redo functionality, as well as for implementing menu systems and multi-level commands.
18.
Which type/category has Memento Pattern?
Correct Answer
C. Behavioral
Explanation
The Memento Pattern falls under the Behavioral category. This pattern is used to capture and restore an object's internal state without violating encapsulation. It provides a way to save and restore the state of an object, allowing it to return to a previous state. This behavior-focused pattern is primarily concerned with the communication and interaction between objects.
19.
Which type/category has Interpreter Pattern?
Correct Answer
C. Behavioral
Explanation
The correct answer is "Behavioral" because the Interpreter Pattern is a design pattern that falls under the behavioral category. This pattern is used to define a grammatical representation for a language and provides a way to interpret sentences in that language. It is commonly used to build interpreters for programming languages or to parse and evaluate mathematical expressions.
20.
Which type/category has Observer Pattern?
Correct Answer
C. Behavioral
Explanation
The Observer Pattern is a design pattern that falls under the category of Behavioral patterns. This pattern defines a one-to-many dependency between objects, where when one object changes its state, all its dependents are notified and updated automatically. This behavior pattern focuses on the communication and interaction between objects, making it a suitable fit for the Observer Pattern.
21.
Which type/category has Chain of Responsibility Pattern?
Correct Answer
C. Behavioral
Explanation
The Chain of Responsibility pattern is a behavioral design pattern. It allows an object to pass a request along a chain of potential handlers until one of them handles the request. This pattern decouples senders and receivers, giving multiple objects the opportunity to handle the request without explicitly specifying the receiver. Therefore, the correct answer is Behavioral.
22.
Which type/category has State Pattern?
Correct Answer
C. Behavioral
Explanation
The State Pattern is a behavioral design pattern. It is used to allow an object to alter its behavior when its internal state changes. This pattern is helpful in scenarios where an object needs to change its behavior based on its internal state, without having to change its class. It promotes loose coupling between objects and allows for better maintainability and extensibility of code.
23.
Which type/category has Strategy Pattern?
Correct Answer
C. Behavioral
Explanation
The correct answer is Behavioral because the Strategy Pattern is a behavioral design pattern that allows you to define a family of algorithms, encapsulate each one, and make them interchangeable. It enables the algorithms to vary independently from clients that use them, promoting code reuse and flexibility.
24.
Which Desing Patterns are Creational Patterns?
Correct Answer(s)
B. Builder
C. Prototypr
F. Abstract Factory
H. Factory Method
J. Singleton
Explanation
5 out of 23 GoF fundamental Design Patterns are Creational Patterns?
25.
Which Desing Patterns are Structural Patterns?
Correct Answer(s)
B. Proxy
D. Decorator
F. Adapter
G. Composite
J. Flyweight
K. Bridge
M. Facade
Explanation
7 out of 23 GoF fundamental Design Patterns are Structural Patterns?
26.
Which Desing Patterns are Behavioral Patterns?
Correct Answer(s)
A. Mediator
B. Visitor
D. Template Method
E. Iterator
F. Command
I. Interpreter
J. Observer
K. Memento
N. Chain of Responsibility
P. State
Q. Strategy
Explanation
11 out of 23 GoF fundamental Design Patterns are Structural Patterns?