CS FundamentalsHardGATE CS · TCS NQT Prime · Product Company SDE

A base class defers the decision of exactly which concrete subclass to instantiate to its subclasses, by exposing a creation method that subclasses override to return their own type. This is:

  1. A. Singleton pattern
  2. B. Builder pattern
  3. C. Abstract Factory pattern
  4. D. Factory Method pattern

Correct answer: D. Factory Method pattern

Factory Method defines a creation method in a base class that subclasses override to decide which concrete product to instantiate, letting the base class's algorithm stay independent of concrete types.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic