Design Patterns Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to Design Patterns Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is correct about Factory design pattern.
A - This type of design pattern comes under creational pattern.
B - Factory pattern creates object without exposing the creation logic to the client.
C - Factory pattern refers to newly created object using a common interface.
Answer : D
Explanation
Factory pattern is one of most used design pattern in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.
Q 2 - Which of the following describes the Bridge pattern correctly?
A - This pattern builds a complex object using simple objects and using a step by step approach.
B - This pattern refers to creating duplicate object while keeping performance in mind.
C - This pattern is used when creation of object directly is costly.
Answer : D
Explanation
Bridge pattern is used when we need to decouple an abstraction from its implementation so that the two can vary independently.
Q 3 - Which of the following describes the Composite pattern correctly?
A - This pattern builds a complex object using simple objects and using a step by step approach.
Answer : B
Explanation
Composite pattern is used where we need to treat a group of objects in similar way as a single object.
Q 4 - Which of the following pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance?
Answer : C
Explanation
Flyweight pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance.
Q 5 - Which of the following pattern a request is wrapped under an object as command and passed to invoker object?
Answer : C
Explanation
A request is wrapped under an object as command and passed to invoker object. Invoker object looks for the appropriate object which can handle this command and passes the command to the corresponding object which executes the command.
Q 6 - Which of the following describes the Visitor pattern correctly?
B - This pattern is used to separate application's concerns.
C - This pattern is used to decouple presentation tier and business tier.
Answer : A
Explanation
In Visitor pattern, a visitor class is used which changes the executing algorithm of an element class.
Q 7 - Which of the following pattern is used to separate low level data accessing API or operations from high level business services?
Answer : A
Explanation
DAO Pattern is used to separate low level data accessing API or operations from high level business services.
Q 8 - Which of the following pattern involves a single class which is responsible to create an object while making sure that only single object gets created?
Answer : C
Explanation
Singleton Pattern involves a single class which is responsible to create an object while making sure that only single object gets created.
Q 9 - Which type of design patterns are specifically concerned with the presentation tier?
A - Creational Design Patterns
Answer : D
Explanation
J2EE Design Patterns are specifically concerned with the presentation tier.
Q 10 - Which of the following is the correct list of entities of DAO pattern?
A - Data Access Object Interface, Data Access Object concrete class, Model Object or Value Object
B - Data Access Object Interface, Model Object or Value Object
C - Data Access Object Interface, Data Access Object concrete class
D - Data Access Object concrete class, Model Object or Value Object
Answer : A
Explanation
Data Access Object Interface, Data Access Object concrete class, Model Object or Value Object are the entities of DAO Pattern.