You want to create a singleton class by using the Singleton design pattern.
Which two statements enforce the singleton nature of the design?
You want to create a singleton class by using the Singleton design pattern.
Which two statements enforce the singleton nature of the design?
To enforce the singleton nature of a class, you should first make the constructor private. This prevents other classes from instantiating the singleton class directly. Second, you need to override the static reference to point to the single instance, ensuring that there is only one instance of the class throughout the application.
B. Make the constructor private. D. Use a static reference to point to the single instance.
B and C are correct.
The answer is BD: B. Make the constructor private. D. Use a static reference to point to the single instance.
Answer B and C.