Factory Pattern Interview Question Part 1

What Is Factory Pattern?

It is the most used design pattern in Java.
These design patterns belong to the Creational Pattern as this pattern provides one of the best ways to create an object.
In the Factory pattern, we don’t expose the creation logic to the client and refer the created object using a standard interface.
Factory Pattern allows the sub-classes to choose the type of objects to create.
The Factory Pattern is also known as Virtual Constructor.

What Is Abstract Factory Pattern?

Abstract Factory Pattern states that define an abstract class or interface for creating families of related objects but without specifying their concrete sub-classes. That means Abstract Factory allowed a class to return a factory of classes. That is why the Abstract Factory Pattern is one level higher than the Factory Pattern.

Abstract Factory patterns work around superclasses, which creates other classes.
The Abstract Factory Pattern comes under Creational Pattern as this pattern provides one of the best ways to create an object.
In the Abstract Factory pattern, an interface is liable for creating a factory of related objects without explicitly identifying their classes.
Each generated factory can give the objects according to the Factory pattern.

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

Back to top