Which statement best describes the Factory Method pattern?

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

Which statement best describes the Factory Method pattern?

Explanation:
Object creation is delegated to subclasses through a factory method, decoupling how objects are created from how they’re used. In this pattern, a creator defines a factory method that returns a product interface. Subclasses override that method to instantiate and return a concrete product. The client code uses the product via its interface, unaware of which concrete class was created. This makes it easy to introduce new products by adding new subclasses without changing the code that uses them, keeping creation isolated from usage. This isn’t about ensuring a single instance (that’s the singleton idea), nor about wrapping an object to add behavior (the decorator idea), nor about converting one interface into another (the adapter idea).

Object creation is delegated to subclasses through a factory method, decoupling how objects are created from how they’re used. In this pattern, a creator defines a factory method that returns a product interface. Subclasses override that method to instantiate and return a concrete product. The client code uses the product via its interface, unaware of which concrete class was created. This makes it easy to introduce new products by adding new subclasses without changing the code that uses them, keeping creation isolated from usage.

This isn’t about ensuring a single instance (that’s the singleton idea), nor about wrapping an object to add behavior (the decorator idea), nor about converting one interface into another (the adapter idea).

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy