Advanced Java Questions & Answers – Design Patterns

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

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

Answer: d
Explanation: 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
View Answer

Answer: b
Explanation: 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
View Answer

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

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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: a
Explanation: 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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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
View Answer

Answer: b
Explanation: 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
View Answer

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

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

Answer: b
Explanation: 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
View Answer

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

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
View Answer

Answer: a
Explanation: 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.

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.