CS FundamentalsHardProduct-company design interview

An app must create a consistent family of UI widgets (Button, Checkbox, Menu) for either a Light or a Dark theme, never mixing a Light button with a Dark menu. Which pattern guarantees this best?

  1. A. Factory Method on each widget class
  2. B. Singleton
  3. C. Builder
  4. D. Abstract Factory, with one concrete factory per theme creating all the related widgets

Correct answer: D. Abstract Factory, with one concrete factory per theme creating all the related widgets

Abstract Factory groups the creation of related products behind one factory per family, so choosing the DarkFactory yields only dark widgets. Factory Method creates one product type at a time and does not enforce family consistency.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic