Question d’entretien chez Resolve Systems

Ask what is the singleton and how do you create a singleton (in coding).

Réponse à la question d'entretien

Utilisateur anonyme

2 mai 2016

In a singleton, the constructors are private. And you need to create an instance variable of the class and set to null. You have a method getInstance of the class. When calling the getInstance, if the variable is null, you create the instance of this class and return the instance. If not, return the instance that you've created.