Design Patterns Mock Test


Advertisements

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.

Questions and Answers

Design Patterns Mock Test II

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?

A - Composite Pattern

B - Facade Pattern

C - Flyweight Pattern

D - Decorator Pattern

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?

A - Composite Pattern

B - Facade Pattern

C - Flyweight Pattern

D - Decorator Pattern

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?

A - Composite Pattern

B - Facade Pattern

C - Flyweight Pattern

D - Decorator Pattern

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?

A - Composite Pattern

B - Facade Pattern

C - Flyweight Pattern

D - Decorator Pattern

Answer : C

Explanation

Flyweight pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance.

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.

Answer : B

Explanation

As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request.

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.

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?

A - Proxy Pattern

B - Chain of Responsibility Pattern

C - Command Pattern

D - Interpreter Pattern

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?

A - Proxy Pattern

B - Chain of Responsibility Pattern

C - Command Pattern

D - Interpreter Pattern

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?

A - Proxy Pattern

B - Chain of Responsibility Pattern

C - Command Pattern

D - Interpreter Pattern

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?

A - Proxy Pattern

B - Chain of Responsibility Pattern

C - Command Pattern

D - Interpreter Pattern

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 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?

A - Iterator Pattern

B - Mediator Pattern

C - Memento Pattern

D - Observer Pattern

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?

A - Iterator Pattern

B - Mediator Pattern

C - Memento Pattern

D - Observer Pattern

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?

A - Iterator Pattern

B - Mediator Pattern

C - Memento Pattern

D - Observer Pattern

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?

A - Iterator Pattern

B - Mediator Pattern

C - Memento Pattern

D - Observer Pattern

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.

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
design_pattern_questions_answers.htm
Advertisements