Public class ClassicSingleton {private static ClassicSingleton instance = null;
ID: 3830284 • Letter: P
Question
Public class ClassicSingleton {private static ClassicSingleton instance = null; protected ClassicSingleton() {} public static ClassicSingleton getInstance() {if(instance == null) {instance = new ClassicSingleton();} return instance;}} Consider the Java code true false-instance = new ClassicSingleton(); will not work because the constructor is protected true false-the Singleton object will be loaded will be created when the class is loaded true false-A class can extend true false-the Singleton object can be accessed even though it is privateExplanation / Answer
a. false
Since we are using it within the class, it would work.
b. false
The singleton object won't be created unless we declare an object.
c. true
A class can extend any class but a final class.
d. true
By calling getInstance () method we can access singleton object
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.