what is the use of private constructor in core java?
Answers were Sorted based on User's Feedback
Answer / rakesh
Private constructor can be used if we do not want any other
class to instantiate the class. This concept is generally
used in Singleton Design Pattern. The instantiation of such
classes is done from a static public method.
| Is This Answer Correct ? | 54 Yes | 3 No |
Answer / rajib
Whenever we r using singleton class then we use constructor
as private.
| Is This Answer Correct ? | 38 Yes | 6 No |
Answer / deep chandra harbola
private constructor are used to create Sinleton class.
example logger class
for singleton class only one object can be created.
by default member of singleton class are static.
singleton class can not be inherited.
| Is This Answer Correct ? | 29 Yes | 3 No |
How do you override a method in java?
what is prepare statement? what is calabedtarement?
Why are functions called methods in java?
What is the purpose of the system class in java?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
0 Answers HCL, SAP Labs, Vital Soft,
Is there any need to import java.lang package?
To obtain design information about an object, which class in used?
What is method reference in java?
What is finalize()?
How is string stored in java?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?
Can we extend a class with private constructor?