Java OCA OCP Practice Question 1440

Question

What design pattern or principle ensures that there will be no more than one instance of a class?

  • A. Encapsulation
  • B. Immutability
  • C. Singleton
  • D. Static


C.

Note

The singleton pattern ensures there will be no more than one instance of the object.

Depending on how it is implemented, it is possible for there to be zero instances.

But it is not possible to have more than one, making Option C correct.




PreviousNext

Related