Professional Documents
Culture Documents
1. Define one to many dependencies between objects so that when one object changes state, its
entire dependent are notified and updated automatically.
a. Chain of Responsibility
b. Event Notification
c. Mediator
d. Observer
2. Ensure a class has only one instance, and provide a global access point to it.
a. Single class factory
b. Proxy
c. Singleton
d. Flyweight
3. Which of the following are participants in the abstract factory design pattern
a. Factory methods
b. Factory constructors
c. Abstract factory
d. Abstract product
e. Concrete factory
6. You want all the clients using class A to use the same instance of class A, what should you do
to achieve this goal?
a. mark class A final
7. Which of the following are participants in the GOF Singleton design pattern?
a. Abstract Singleton
b. Singleton
c. Concrete Singleton
d. Singleton factory
8. When would you use the GOF Singleton design pattern? (choose all that apply)
a. to ensure that a certain group of related objects are used together
b. to limit the class instantiation to one object
c. to provide global access to once instance across the system
d. to abstract steps of construction of complex objects
9. When would you use the GOF abstract factory pattern? (choose all that apply)
a. To design a structure which has a uniform interface for both compositions of objects
and individual objects
b. To ensure that a certain group of related objects are used together
c. The client which uses your design is not dependent on how the object are created or
connected together
d. To decouple the creation of objects from their usage
10. You want to create families of related objects, to be used interchangeably to configure
you application. What is the most appropriate pattern to use?
a. Chain of Responsibility
b. Abstract Factory
c. Builder
d. Observer
1. Which design pattern you would you use to decouple an abstraction from its implementation
so that the two can vary independently?
a. Adapter design pattern
b. bridge design pattern
c. Facade design pattern
d. Composite bridge design pattern
2. When would you use the GOF Bridge design pattern? (choose all that apply)
a. to implement lazy loading of expensive objects
b. to improve system reliability and scalability
c. to decouple an abstraction from its implementation so that the two can vary
independently
d. to hide the implementation details from the client code of your design
3. Which of the following are participants in the GOF bridge design pattern?
a. Bridge
b. RefinedAbstraction
c. Class Generalization
d. Implementor
e. Abstraction
4. You design an application for an advertis-ement company, which produces different sort of
publications such as books, articles, leaflets, etc.The company publishes those products in
many media formats such as printed material, CD, DVD, online websites, etc. How you would
model the company products hierarchy (Publications, Media)?
a. Use composite design pattern to enable the publication and media hierarchies to be
treated in the same way as a single instance of an object.
b. Use the adapter design pattern to translates publication interface into a compatible
media interface.
c. Use bridge design pattern to build separate hierarchies for the publications and the
media, to decouple the abstraction from its implementation so that the two can vary
independently
6. In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and
are notified when new messages arrive to the topic. Which pattern does most describe this
model?
a. Adapter
a. Notifier
b. Observer
c. State
7. Compact Computers is a small computer assembly company. Any customer currently has the
following choices for a PC:
The use of what design pattern would ensure that only the legal combinations could be sold?
a. Factory Method
b. Prototype
c. Abstract Factory
d. Singleton
8. Which of the following code snippet represents a Singleton design pattern implementation?
a. public class PrintSpooler {
public PrintSpooler INSTANCE = new PrintSpooler();
public PrintSpooler () {}
public static PrintSpooler getInstance() {
return INSTANCE;
}
}
b. public class PrintSpooler {
private PrintSpooler INSTANCE = new PrintSpooler();
private PrintSpooler () {}
public static PrintSpooler getInstance() {
return INSTANCE;
}
}
c. public class PrintSpooler {
private static final PrintSpooler INSTANCE = new
PrintSpooler();
private PrintSpooler () {}
public static PrintSpooler getInstance() {
return INSTANCE;
}
}
d. public class PrintSpooler {
private final PrintSpooler INSTANCE = new PrintSpooler();
private PrintSpooler () {}
public static PrintSpooler getInstance() {
return INSTANCE;
}
}
9. Having the following design patterns, please partition them into creational design patterns,
structural design patterns, behavioural design patterns.
Abstract Factory Pattern
Bridge Pattern
Singleton Pattern
Observer Pattern
Feedback:
Incorrect
Answers:
Date:
Score: