public class ClassicSingleton private static ClassicSingleton instance null; pro
ID: 3716180 • Letter: P
Question
public class ClassicSingleton private static ClassicSingleton instance null; protected ClassicSingleton() public static ClassicSingleton getlnstance(){ if instance null) instance new ClassicSingleton) return instance; true true true true false - if the instance was made public then many instance objects could be made false - if the constructor was public, it would still follow the Singleton Pattern false - if the instance variable was initialized to new ClassicSingletonO, objects created is unaffected false- when the class is loaded, the singleton object is not createdExplanation / Answer
Answer by following way
1.True
2.false
Well, you can...but then it isn't a singleton class.
The idea of a singleton class is that it only allows a single instance of the class to exist - so making the constructor public circumvents this by allowing the world outside the class to call the constructor and create as many instances as it wanted: unless the constructor looked for this and threw a run-time error. Which is poor design, because it creates runtime problems that should have been caught as compile time!
3.True
4.False
Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.