Sei sulla pagina 1di 8

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

4. What are the consequences of applying the GOF Singleton


pattern?

a. it introduces thread safety issue when the singleton


instance is instantiated on demand
b. the client code can creates multiple instances at run time
c. it reduces of the class hierarchy as compared to the other
factory design patterns
d. it makes it easier for a certain family of objects to work
together
5. What are the consequences of applying the abstract factory
patter?
a. it will be much easier to introduce new family of products
b. it makes it easier for a certain family of objects to work
together
c. it makes it easier for the client to deal with tree-
structured data
d. it makes the designed product families exchangeable

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


b. mark class A abstract
c. apply the Singleton pattern to class A
d. apply the Memento pattern to class A

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
11. 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
12. 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

13. Which of the following are participants in the GOF bridge


design pattern?

a. Bridge
b. RefinedAbstraction
c. Class Generalization
d. Implementor
e. Abstraction

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

15. What are the consequences of applying the GOF Bridge


pattern?

a. it makes implementing the client code easier by


interacting with a single uniform interface
b. it decouples an abstraction from its
implementation so that the two can vary
independently
c. it will decrease the system extesibility
d. the client code can traverse tree structures of
arbitrary depth recursively

16. 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
b. Notifier
c. Observer
d. State

17. Compact Computers is a small computer assembly


company. Any customer currently has the following choices for
a PC:

(i) 800 MHz processor, 40 GB HDD, 128 MB RAM


(ii) 1 GHz processor, 60 GB HDD, 256 MB RAM
(iii) 1.2 GHz processor, 80 GB HDD, 512 MB RAM
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

18. 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;
}
}

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

20. Consider the following UML diagram


.
a. First, identify the pattern in the diagram
b. Second, identify the participants in the diagram and
indicate their responsibilities.

Potrebbero piacerti anche