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 |
What happens if an exception is throws from an object's destructor?
Which is the best way of exception handling?
What are advantages of using Java?s layout managers than windowing systems?
What is a void method java?
What are different types of arrays?
What is the difference between comparison done by equals method and == operator?
How to write custom exception in java?
What are different access specifiers in java? Explain
What is string immutability?
What does @param args mean in java?
What do you understand by private, protected and public?
How do you clear a method in java?