Interview Questions and Answers For Design Patterns

by Rupa.R, on Sep 10, 2022 4:23:03 PM

Interview Questions (34)1.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.

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

3.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

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

5.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.

6.Can we create a clone of a singleton object?
Yes

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

8.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.

9.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.

10.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.

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

Topics:Interview Questions with Answers

Comments

Subscribe