0
Is this a correct Singleton implementation?
While preparing for a quiz, I have come accross a question about the Singleton design pattern. The code had these: - public final static instance - instance being initialized in a static block - private constructor The possible answers: a) correct Singleton implementation b) wrong Singleton implementation c) an example of lazy initialization d) an example of eager initialization e) to be a Singleton, it requires a getInstance() method f) it cannot be considered an implementation of a Design Pattern Personally I would say that b) and e) are correct, but someone else told me that the correct answers are a) and d). Can someone enlighten me? Thank you in advance!
1 Resposta
0
this is a correct singleton implementation as you get an unique class instance (eager initialized in static block, do you doesn't need a getInstance() method)... as correct singleton implementation it can be considered as implementation of design pattern ;)