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 are implicit objects in java?
What is the purpose of garbage collection in java? When is it used?
What are the differences between string, stringbuffer and stringbuilder?
extending thread class or implementing runnable interface. Which is better? : Java thread
Explain java heap space and garbage collection?
What is the default access specifier for variables and methods of a class?
Why declare Main() inside the class in java ?
Definition for connection pooling?
Why strings in java are called as immutable?
Is a copy constructor?
How are this() and super() used with constructors in java programming?
By what default value is an object reference declared as an instance variable?