CS FundamentalsHardProduct-company design interview

A document-editor framework defines an abstract Application class with a method newDocument() that calls createDocument(); each concrete app (TextApp, DrawingApp) overrides createDocument() to return its own document type. Which pattern is this?

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

Correct answer: B. Factory Method

Factory Method lets subclasses decide which class to instantiate through an overridable creation method used by the base class's own logic. Abstract Factory is a separate object creating a family of products.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic