Pergunta de entrevista da empresa ALTEN

What's a Singleton Pattern? How would you implement it in Java?

Resposta da entrevista

Sigiloso

27 de mar. de 2019

The Singleton Pattern is a software design pattern that guarantees a class has one instance only and a global point of access to it is provided by that class. Anytime multiple classes or clients request for that class, they get the same instance of the class. This Singleton class may be responsible for instantiating itself, or you can delegate the object creation to a factory class. I use Singleton design pattern for example in Fragments,Dialogs,Custom Dialogs, by make a singleton object to call any fragment or dialog with only instance as a global point of access.