Object-Oriented Programming · Question 25 · Medium

Which design pattern ensures that a class has only one instance and provides a global point of access to it?

  1. Factory Method
  2. Singleton
  3. Observer
  4. Decorator
Answer and explanation

Answer: B. Singleton

Explanation: Singleton uses a private constructor and a static accessor that always returns the same instance. Factory Method creates objects, Observer notifies dependents of changes, and Decorator adds behaviour by wrapping.

Previous: Which SOLID principle says a class should have only one reason to change? · Next: A House is made of Rooms, and the Rooms cannot exist without the House: when…

Practise object-oriented programming

Try a fresh set of object-oriented programming questions with an explanation after every answer, free and without signing up: Object-Oriented Programming practice. Or sit a full placement mock test.

More object-oriented programming questions

More technical & programming practice

DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge