B.S.W.E. Bachelor of Software Engineering Software Architecture & Design Patterns 1 — Questions and Answers
Question 1: What design pattern ensures only one instance of a class exists?
- Factory
- Singleton (Correct answer)
- Observer
- Decorator
Correct answer: Singleton
The Singleton pattern restricts instantiation of a class to a single object throughout the application lifecycle.
Question 2: Which architectural pattern separates an application into Model, View, and Controller?
- REST
- MVVM
- MVC (Correct answer)
- SOA
Correct answer: MVC
MVC divides application logic into Model (data), View (UI), and Controller (business logic) components.
Question 3: What pattern allows incompatible interfaces to work together?
- Bridge
- Adapter (Correct answer)
- Facade
- Proxy
Correct answer: Adapter
The Adapter pattern converts the interface of a class into another interface that clients expect, enabling compatibility.
Question 4: Which design pattern defines a skeleton of an algorithm in a base class?
- Strategy
- Command
- Template Method (Correct answer)
- Chain of Responsibility
Correct answer: Template Method
The Template Method pattern defines the program skeleton in a base class while allowing subclasses to override specific steps.
Question 5: In microservices architecture, what is the primary benefit of service decomposition?
- Increased coupling
- Independent deployability (Correct answer)
- Single codebase
- Centralized data
Correct answer: Independent deployability
Microservices allow each service to be independently developed, deployed, and scaled without affecting other services.
Question 6: Which pattern encapsulates a request as an object to support undoable operations?
- Observer
- Iterator
- Command (Correct answer)
- Visitor
Correct answer: Command
The Command pattern encapsulates requests as objects, allowing parameterization, queuing, logging, and undo operations.
What design pattern ensures only one instance of a class exists?