Interview Questions and Answers For Design Patterns

What is Design Pattern?
Design Pattern In software is a best practice a general, reusable solution to a common problem faced by software developers within a given context in software design.
Design patterns are best practices that programmer can use to solve common problems when designing a system or application.

What are the types of Design Patterns?
Creational Patterns
Structural Patterns
Behavioral Patterns

What is meant by Gang of Four GOF?
The four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides These authors are collectively known as Gang of Four GOF.
These initiated the concept of Design Pattern in Software development In 1994 & published a book titled Design Patterns – Elements of Reusable Object-Oriented Software

What are J2EE Patterns?
J2EE Patterns concerned with the presentation tier.

What is Factory pattern?
Factory pattern is one of the most used design patterns in Java. … In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

Can we create a clone of a singleton object?

How to create Singleton class in java?
There are two steps in this process.
First, make the constructor private so that new operator cannot be used to instantiate the class.
Return an object of the object if not null otherwise create the object and return the same via a method.

What is the benefit of Factory pattern?
Factory pattern encapsulates the implementation details and underlying implementation can be changed without any impact on caller api.

What is Singleton pattern?
In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

What is Abstract Factory pattern?
Abstract factory pattern is also called factory of factories.The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes.

How to prevent cloning of a singleton object?
By Throwing exception within the body of clone method.

Review Date
Reviewed Item
Thank you for your Design Patterns Interview Questions and Answers
Author Rating