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?
- A. Factory Method
- B. Abstract Factory
- C. Builder
- 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
- In C++11 and later, which statement about this 'Meyers singleton' is correct? cpp Logger& instance() { static Logger log; return log; }
- How many of these are resolved at COMPILE time in C++? (i) Which function body a call to a non-virtual member function through a…
- What is printed? java String b = "java"; String a = "ja" + "va"; String c = "ja"; String d = c + "va"; final String e = "ja"; String f = e…
- What is printed? java class A { void f(Object o) { System.out.print("AO "); } void f(String s) { System.out.print("AS "); } } class B…
- What is printed? java class P { String n = "P"; String get() { return n; } } class C extends P { String n = "C"; String get() { return n…
- What is printed? java class P { P() { show(); } void show() { System.out.print("P "); } } class C extends P { int x = 5; final int y = 7…