JAVA DESIGN PATTERN Questions and Answers

Explain how can you create a Singleton class in Java?

It is two step process,

  • First make the constructor private so that new operator cannot be used to instantiate the class
  • Return an object of the object if not null otherwise create the object and return the same via a method.