Skip to main content

Explain the Factory design pattern.

Mid Java
Quick Answer Factory pattern creates objects without exposing instantiation logic to the client. Factory Method: subclass decides which class to instantiate. Abstract Factory: family of related objects created together. Benefits: decouples creation from usage, easy to swap implementations, centralize creation logic. Spring's ApplicationContext is a factory - you ask for a bean, it creates/returns it.

Answer

Factory pattern creates objects without exposing creation logic.
Promotes loose coupling and extensibility.
Used in dependency injection and plugin architectures.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice