Factory Pattern — Concept Check
Questions on Factory Pattern. Factory patterns decouple object creation from usage, enabling flexible instantiation without tight coupling to concrete types.
Questions in this quiz
6 questions on Factory Pattern — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer uses a static factory method to create instances of a class. What advantage does this provide over constructors?
- AIt can return a cached instance.
- BIt always creates a new instance.
- CIt requires less memory.
- DIt simplifies the class structure.
2.In a UI application, you need to ensure consistent look and feel across components. Which pattern should you use?
- ASingleton Pattern
- BFactory Method Pattern
- CStatic Factory Method
- DAbstract Factory Pattern
3.Which pattern allows subclasses to determine which class to instantiate?
- ABuilder Pattern
- BStatic Factory Method
- CFactory Method Pattern
- DAbstract Factory Pattern
4.A developer wants to create a pool of reusable objects to improve performance. Which feature of static factory methods supports this?
- AReturning subtypes
- BAvoiding object creation
- CMeaningful method names
- DReturning cached instances
5.In a messaging service, different types of notifications are sent using a factory method. What is the benefit?
- AIt simplifies the message format.
- BIt ensures all notifications are sent simultaneously.
- CIt reduces the number of classes needed.
- DIt allows dynamic notification type selection.
6.What is a key characteristic of the Factory Method Pattern in framework design?
- AIt always returns the same instance.
- BIt simplifies object creation logic.
- CIt uses inheritance to decide instantiation.
- DClients must know concrete classes.