- Design Patterns Tutorial
- Design Patterns - Home
- Design Patterns - Overview
- Design Patterns - Factory Pattern
- Abstract Factory Pattern
- Design Patterns - Singleton Pattern
- Design Patterns - Builder Pattern
- Design Patterns - Prototype Pattern
- Design Patterns - Adapter Pattern
- Design Patterns - Bridge Pattern
- Design Patterns - Filter Pattern
- Design Patterns - Composite Pattern
- Design Patterns - Decorator Pattern
- Design Patterns - Facade Pattern
- Design Patterns - Flyweight Pattern
- Design Patterns - Proxy Pattern
- Chain of Responsibility Pattern
- Design Patterns - Command Pattern
- Design Patterns - Interpreter Pattern
- Design Patterns - Iterator Pattern
- Design Patterns - Mediator Pattern
- Design Patterns - Memento Pattern
- Design Patterns - Observer Pattern
- Design Patterns - State Pattern
- Design Patterns - Null Object Pattern
- Design Patterns - Strategy Pattern
- Design Patterns - Template Pattern
- Design Patterns - Visitor Pattern
- Design Patterns - MVC Pattern
- Business Delegate Pattern
- Composite Entity Pattern
- Data Access Object Pattern
- Front Controller Pattern
- Intercepting Filter Pattern
- Service Locator Pattern
- Transfer Object Pattern
Design Patterns Mock Test
This section presents you various set of Mock Tests related to Design Patterns Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Design Patterns Mock Test II
Q 1 - 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 2 - Which of the following describes the Decorator pattern correctly?
Answer : A
Explanation
Decorator pattern allows a user to add new functionality to an existing object without altering its structure.
Q 3 - Which of the following describes the Facade pattern correctly?
Answer : C
Explanation
Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system.
Q 4 - Which of the following describes the Flyweight pattern correctly?
Answer : C
Explaination
This 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 is used where we need to treat a group of objects in similar way as a single object?
Answer : A
Explanation
Composite Pattern is used where we need to treat a group of objects in similar way as a single object.
Q 6 - Which of the following pattern allows a user to add new functionality to an existing object without altering its structure?
Answer : D
Explanation
Decorator Pattern allows a user to add new functionality to an existing object without altering its structure.
Q 7 - Which of the following pattern hides the complexities of the system and provides an interface to the client using which the client can access the system?
Answer : B
Explanation
Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system.
Q 8 - 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 9 - Which of the following describes the Proxy pattern correctly?
A - In this pattern a class represents functionality of another class.
B - This pattern creates a chain of receiver objects for a request.
C - This pattern provides a way to evaluate language grammar or expression.
D - In this pattern a request is wrapped under an object as command and passed to invoker object.
Answer : A
Explanation
In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern. In proxy pattern, we create object having original object to interface its functionality to outer world.
Q 10 - Which of the following describes the Chain of Responsibility pattern correctly?
A - In this pattern a class represents functionality of another class.
B - This pattern creates a chain of receiver objects for a request.
C - This pattern provides a way to evaluate language grammar or expression.
D - In this pattern a request is wrapped under an object as command and passed to invoker object.
Answer : B
Explanation
As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request.
Q 11 - Which of the following describes the Command pattern correctly?
A - In this pattern a class represents functionality of another class.
B - This pattern creates a chain of receiver objects for a request.
C - This pattern provides a way to evaluate language grammar or expression.
D - In this pattern a request is wrapped under an object as command and passed to invoker object.
Answer : D
Explanation
Command pattern is a data driven design pattern and falls under behavioral pattern category. 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 12 - Which of the following describes the Interpreter pattern correctly?
A - In this pattern a class represents functionality of another class.
B - This pattern creates a chain of receiver objects for a request.
C - This pattern provides a way to evaluate language grammar or expression.
D - In this pattern a request is wrapped under an object as command and passed to invoker object.
Answer : C
Explanation
Interpreter pattern provides a way to evaluate language grammar or expression. This type of pattern comes under behavioral pattern. This pattern involves implementing an expression interface which tells to interpret a particular context.
Q 13 - In which of the following pattern a class represents functionality of another class?
Answer : A
Explanation
In proxy pattern, a class represents functionality of another class. In proxy pattern, we create object having original object to interface its functionality to outer world.
Q 14 - Which of the following pattern creates a chain of receiver objects for a request?
Answer : B
Explanation
As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request.
Q 15 - Which of the following pattern provides a way to evaluate language grammar or expression?
Answer : D
Explanation
Interpreter pattern provides a way to evaluate language grammar or expression.
Q 16 - 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 17 - Which of the following describes the Iterator pattern correctly?
B - This pattern is used to reduce communication complexity between multiple objects or classes.
C - This pattern is used to restore state of an object to a previous state.
Answer : A
Explanation
This pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation.
Q 18 - Which of the following describes the Mediator pattern correctly?
B - This pattern is used to reduce communication complexity between multiple objects or classes.
C - This pattern is used to restore state of an object to a previous state.
Answer : B
Explanation
This pattern is used to reduce communication complexity between multiple objects or classes.
Q 19 - Which of the following describes the Memento pattern correctly?
B - This pattern is used to reduce communication complexity between multiple objects or classes.
C - This pattern is used to restore state of an object to a previous state.
Answer : C
Explanation
This pattern is used to restore state of an object to a previous state.
Q 20 - Which of the following describes the Observer pattern correctly?
B - This pattern is used to reduce communication complexity between multiple objects or classes.
C - This pattern is used to restore state of an object to a previous state.
Answer : D
Explanation
This pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically.
Q 21 - Which of the following pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation?
Answer : A
Explanation
Iterator pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation.
Q 22 - Which of the following pattern is used to reduce communication complexity between multiple objects or classes?
Answer : B
Explanation
Mediator pattern is used to reduce communication complexity between multiple objects or classes.
Q 23 - Which of the following pattern is used to restore state of an object to a previous state?
Answer : C
Explanation
Memento pattern is used to restore state of an object to a previous state.
Q 24 - Which of the following pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically?
Answer : A
Explanation
Observer Pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically.
Q 25 - Which of the following describes the State pattern correctly?
A - In this pattern, a class behavior changes based on its state.
B - In this pattern, a null object replaces check of NULL object instance.
C - In this pattern, a class behavior or its algorithm can be changed at run time.
D - In this pattern, an abstract class exposes defined way(s)/template(s) to execute its methods.
Answer : A
Explanation
In State pattern, a class behavior changes based on its state.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | B |
2 | A |
3 | C |
4 | C |
5 | A |
6 | D |
7 | B |
8 | C |
9 | A |
10 | B |
11 | D |
12 | C |
13 | A |
14 | B |
15 | D |
16 | C |
17 | A |
18 | B |
19 | C |
20 | D |
21 | A |
22 | B |
23 | C |
24 | A |
25 | A |