Singleton Consequences - Quiz Explanation

The correct answers are indicated below, along with explanations of why those answers are correct.
 
1. What kind of pattern is Singleton?
Please select the best answer.
  A. object creational
  B. object structural
  C. class behavioral
  D. class creational
  The correct answer is A.
In the GoF classification, Singleton is a creational pattern because it focuses on controlling object creation—specifically ensuring there is a single accessible instance. In many GoF diagrams and discussions, Singleton is treated as an object pattern because clients obtain an object reference and collaborate through that single instance.

2. The collaborations in a design pattern describe:
Please select the best answer.
  A. The classes that collaborate with one another to form the pattern
  B. How classes and objects outside the pattern interact with the pattern
  C. How functions in the pattern invoke other functions in the pattern
  D. How methods in the pattern invoke other methods in the pattern
  The correct answer is B.
Collaborations describe how the pattern’s participants work together and how clients interact with the pattern through its public interface. Design patterns are described at the level of classes and objects, not at the level of individual methods calling other methods.

3. Which of the following is a consequence of the Singleton?
Please select the best answer.
  A. Pure static members lend themselves to subclassing
  B. Different subclasses can be configured randomly
  C. The Singleton object can be used by one object at a given time
  D. Access to the object is controlled
  The correct answer is D.
A common consequence of Singleton is controlled access to the shared instance. Because the instance is not constructed directly by clients, all access flows through a single entry point (for example, getInstance()), where the class can apply policies such as lazy creation, access checks, throttling, or synchronization.

A is incorrect: a “pure static” design generally does not lend itself to subclassing in a useful way, and it reduces flexibility compared to an instance-based design.
B is incorrect: selecting a subclass at runtime is a deliberate configuration decision, not something done “randomly.”
C is incorrect: Singleton does not imply exclusive use by only one client at a time; multiple clients can hold the same reference concurrently. Exclusive access (mutual exclusion) is a separate concurrency concern.

4. A Singleton class would best be used to represent:
Please select the best answer.
  A. A parallel port
  B. A serial port
  C. A computer's audio device
  D. A monitor
  The correct answer is C.
Within the module’s narrative, an audio device is a good example of a single shared resource that benefits from a single coordinator (for example, centralized queuing or arbitration). Ports and monitors can exist in multiples, and modern systems also virtualize device endpoints. The key Singleton idea is not “hardware can only be one,” but “the application needs one consistent coordinator for that resource.”

Return to Quiz