1.

What is true about private constructor?(a) Private constructor ensures only one instance of a class exist at any point of time(b) Private constructor ensures multiple instances of a class exist at any point of time(c) Private constructor eases the instantiation of a class(d) Private constructor allows creating objects in other classesThis question was posed to me in quiz.Origin of the question is Constructor in portion Classes and Methods of Java

Answer»

The correct option is (a) Private CONSTRUCTOR ensures only one instance of a CLASS exist at any point of time

For explanation: OBJECT of private constructor can only be created within class. Private constructor is USED in singleton pattern.



Discussion

No Comment Found

Related InterviewSolutions