Which design pattern ensures a class has only one instance?
A
Factory
B
Singleton
C
Observer
D
Adapter
Correct Answer: Option B — Singleton
Explanation:
The Singleton design pattern ensures that a class has only one instance throughout the program's execution and provides a global point of ac...
The Singleton design pattern ensures that a class has only one instance throughout the program's execution and provides a global point of access to that instance. It is commonly used for managing shared resources like configuration settings.