Design Patterns Online Quiz


Advertisements

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.

Questions and Answers

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 - Integer.valueOf is an example of Factory pattern.

A - false

B - true

Answer : B

Explanation

true. Integer.valueOf() returns a Integer instance representing the specified int value.

Q 3 - Which of the following pattern is used when we need to decouple an abstraction from its implementation so that the two can vary independently?

A - Bridge Pattern

B - Adapter Pattern

C - Prototype Pattern

D - Filter Pattern

Answer : A

Explanation

Bridge pattern is used when we need to decouple an abstraction from its implementation so that the two can vary independently.

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?

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.

Q 6 - In which of the following pattern, a null object replaces check of NULL object instance?

A - State Pattern

B - Null Object Pattern

C - Strategy Pattern

D - Template Pattern

Answer : B

Explanation

In Null Object pattern, a null object replaces check of NULL object instance.

Q 8 - Which of the following pattern is used when we want to locate various services using JNDI lookup?

A - DAO Pattern

B - Front Controller Pattern

C - Intercepting Pattern

D - Service Locator Pattern

Answer : D

Explanation

Service Locator Pattern is used when we want to locate various services using JNDI lookup.

Q 9 - Which type of design patterns concern class and object composition?

A - Creational Design Patterns

B - Structural Design Patterns

C - Behavioral Design Pattern

D - J2EE Design Patterns

Answer : B

Explanation

Structural Design Patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.

Answer : B

Explanation

Service, Context, Service Locator, Cache, Client are the entities of Service Locator pattern.

design_pattern_questions_answers.htm
Advertisements