Sonatype Interview Question: How would you implement the S... | Glassdoor

Interview Question

Software Engineer Interview

How would you implement the Singleton pattern?

Answer

Interview Answer

1 Answer

1

Create a class with a private constructor. Add a static method that checks if an instance of the object is instantiated. If it is - return that instance - otherwise create a new instance of the object and return that.

Interview Candidate on Aug 26, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.