Section 7: Design Patterns
Q1. Which design pattern is best suited for creating a family of related objects?
• A) Singleton
• B) Factory
• C) Abstract Factory
• D) Adapter
Q2. In which design pattern is a single instance of a class restricted?
• A) Prototype
• B) Singleton
• C) Builder
• D) Proxy
Q3. Which pattern allows behavior to be added to an individual object without affecting
others of the same class?
• A) Singleton
• B) Observer
• C) Decorator
• D) Adapter
Q4. What type of pattern is the Observer pattern?
• A) Creational
• B) Structural
• C) Behavioral
• D) Factory
Q5. Which design pattern separates the construction of a complex object from its
representation?
• A) Builder
• B) Factory
• C) Singleton
• D) Adapter
Q6. Which of the following is a feature of the Adapter pattern?
• A) Adapts interfaces of different classes
• B) Creates a family of related objects
• C) Controls object access
• D) Defines an object for undefined behavior
Q7. Which design pattern involves creating a duplicate of an existing object?
• A) Singleton
• B) Prototype
• C) Factory
• D) Decorator
Q8. In the MVC pattern, where is business logic generally handled?
• A) Model
• B) View
• C) Controller
• D) Proxy
Q9. Which design pattern would be most appropriate for managing expensive-to-create
resources?
• A) Factory
• B) Prototype
• C) Proxy
• D) Singleton
Q10. The Command pattern is typically used for what purpose?
• A) To encapsulate requests as objects
• B) To allow a single method for various commands
• C) To restrict object creation
• D) To clone complex objects