asked 120k views
2 votes
The class in Singleton design pattern

a. controls its own instantiation:
b. controls its own movement
c. is responsible for delegation
d. does not control its own movement

1 Answer

3 votes

Final answer:

The Singleton design pattern controls its instantiation by ensuring only one instance of a class exists and providing a global access point. It achieves this via a private constructor and a static method to manage and provide access to the singular instance.

Step-by-step explanation:

The Singleton design pattern in object-oriented programming ensures that a class has only one instance and provides a global point of access to it. The correct answer to the question is a) controls its instantiation. This means that the Singleton class is designed in such a way that it restricts the instantiation of a class to one single instance. This pattern is useful when exactly one object is needed to coordinate actions across the system.

Singletons typically contain a static method that acts as a constructor and is responsible for creating or returning a single instance. Because the constructor is private, it prevents any other class from instantiating another version of the Singleton class. Whenever other components require access to the instance, they call the Singleton’s static method, which ensures that they will receive the instance that was created and managed by the Singleton class itself.

answered
User Vineethbc
by
7.7k points