Design Patterns
Total Marks: 30
Duration: 30 mins
Q1. Which design pattern is used in the Java Database connectivity JDBC(TM)?
Please choose only one answer:
a) Builder design pattern
b) Factory method design pattern
c) Abstract Factory design Pattern
d) Singletone design Pattern
Q2. Which design pattern you would you use to have a prototypical instance determine the concrete
class of object being created?
Please choose only one answer:
a) Prototype factory design pattern
b) Virtual prototype design pattern
c) Abstract prototype design pattern
d) Prototype design pattern
Q3. Which of the following are participants in the GOF Prototype design pattern?
Please choose all the answers that apply:
a) Prototype
b) Abstract Prototype
c) Virtual Prototype
d) Concrete Prototype
Q4. When would you use the GOF Prototype design pattern?
Please choose all the answers that apply:
a) To abstract steps of construction of complex objects
b) To determine the classes to be instantiated at run time
c) To avoid the proliferation of the class hierarchy
d) To restrict class instantiation to one object
Q5. What are the consequences of applying the GOF Prototype pattern?
Please choose all the answers that apply:
a) each concrete prototype class must implement the clone method
b) it makes it easier for a certain family of objects to work together
c) it enable the client code to register an new concrete prototype instance at run time
d) it reduces of the class hierarchy as compared to the other factory design patterns
Q6. Which design pattern you would you use to limit the class instantiation to one object?
Please choose only one answer:
a) Factory Method Design Pattern
b) Builder design pattern
c) Prototype design pattern
d) Singleton design pattern
Q7. When would you use the GOF Singleton design pattern?
Please choose all the answers 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
Q8. Which of the following are participants in the GOF Singleton design pattern?
Please choose all the answers that apply:
a) Abstract Singleton
b) Singleton
c) Concrete Singleton
d) Singleton factory
Q9. How to implement the Singleton design pattern? specify all the needed steps that apply.
Please choose all the answers that apply:
add final modifier to the Class declaration
add final modifier to the constructor declaration
add private or protected modifier to the constructor declaration
introduce a final static constructor of the Singleton class
introduce a static getter method for the Singleton instance
The class name must be Singleton
Q10. What are the consequences of applying the GOF Singleton pattern?
Please choose all the answers that apply:
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
Q11. Which of the following is a Gang of Four (GoF) Structural Design Pattern?
Please choose all the answers that apply:
a) Composite
b) Flyweight
c) Singleton
d) Method Factory
Q13. Which best defines the use of the Composite Design Pattern?
Please choose only one answer:
a) the Composite design pattern allows the clients to build a complex object of smaller different
ones
b) the Composite design pattern allows adding and removing functionality dynamically
c) the Composite design pattern allows the clients to treat individual objects and compositions
uniformly
Q14. It is also known as Wrapper, it is used when subclassing is not possible or practical to add
functionality and it is
used to add functionality at runtime. This pattern is :
Please choose only one answer:
a) Composite
b) Adapter
c) Decorator
d) Proxy
Q15, Big portion of clients are remotely invoking methods in your system, the surface area exposed to
clients includes fine-grained methods, which of course causes network overhead.
Which pattern would improve your system performance in this case?
Please choose only one answer:
a) Chain of Responsibility Pattern
b) Facade Pattern
c) Command Pattern
d) Adapter Pattern