ProgrammingHardGATE CS · Product-company placement

A GUI toolkit must create a matching Button, Checkbox and Window for either a Windows or a Mac theme, guaranteeing that all widgets come from the same family. Which creational pattern fits best?

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

Correct answer: B. Abstract Factory

An Abstract Factory provides an interface for creating a whole family of related products; choosing WindowsFactory or MacFactory guarantees consistent widgets. Factory Method creates a single product type.

More OOP with C++ and Java questions

Exams that ask this topic