Advanced 250+ TOP MCQs on Design Patterns and Answers

This set of Advanced Java Multiple Choice Questions & Answers (MCQs) on “Design Patterns”.

1. Which of the below is not a valid design pattern?
a) Singleton
b) Factory
c) Command
d) Java

Answer: d
Clarification: Design pattern is a general repeatable solution to a commonly occurring problem in software design. There are various patterns available for use in day to day coding problems.

2. Which of the below author is not a part of GOF (Gang of Four)?
a) Erich Gamma
b) Gang Pattern
c) Richard Helm
d) Ralph Johnson

Answer: b
Clarification: Four authors named Richard Helm, Erich Gamma, Ralph Johnson and John Vlissides published a book on design patterns. This book initiated the concept of Design Pattern in Software development. They are known as Gang of Four (GOF).

3. Which of the below is not a valid classification of design pattern?
a) Creational patterns
b) Structural patterns
c) Behavioural patterns
d) Java patterns

Answer: d
Clarification: Java patterns is not a valid classification of design patterns. The correct one is J2EE patterns.

4. Which design pattern provides a single class which provides simplified methods required by client and delegates call to those methods?
a) Adapter pattern
b) Builder pattern
c) Facade pattern
d) Prototype pattern

Answer: c
Clarification: Facade pattern hides the complexities of the system and provides an interface to the client using which client can access the system.

5. Which design pattern ensures that only one object of particular class gets created?
a) Singleton pattern
b) Filter pattern
c) State pattern
d) Bridge pattern

Answer: a
Clarification: Singleton pattern involves a single class which is responsible to create an object while making sure that only one object gets created. This class provides a way to access the only object which can be accessed directly without need to instantiate another object of the same class.

6. Which design pattern suggests multiple classes through which request is passed and multiple but only relevant classes carry out operations on the request?
a) Singleton pattern
b) Chain of responsibility pattern
c) State pattern
d) Bridge pattern

Answer: b
Clarification: Chain of responsibility pattern creates a chain of receiver objects for a particular request. The sender and receiver of a request are decoupled based on the type of request. This pattern is one of the behavioral patterns.

7. Which design pattern represents a way to access all the objects in a collection?
a) Iterator pattern
b) Facade pattern
c) Builder pattern
d) Bridge pattern

Answer: a
Clarification: Iterator pattern represents a way to access the elements of a collection object in sequential manner without the need to know its underlying representation.

8. What does MVC pattern stands for?
a) Mock View Control
b) Model view Controller
c) Mock View Class
d) Model View Class

Answer: b
Clarification: Model represents an object or JAVA POJO carrying data.View represents the visualization of the data that model contains. The controller acts on both model and view. It is usually used in web development.

9. Is design pattern a logical concept.
a) True
b) False

Answer: a
Clarification: Design pattern is a logical concept. Various classes and frameworks are provided to enable users to implement these design patterns.

10. Which design pattern works on data and action taken based on data provided?
a) Command pattern
b) Singleton pattern
c) MVC pattern
d) Facade pattern

Answer: a
Clarification: Command pattern is a data driven design pattern. It is a behavioral pattern. A request is wrapped under an object as command and passed to the invoker object. The invoker object looks for the appropriate object which can handle this command and passes this command to the corresponding object which executes the command.

Leave a Reply

Your email address will not be published. Required fields are marked *