what is the use of private constructor in core java?

Answers were Sorted based on User's Feedback



what is the use of private constructor in core java?..

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

what is the use of private constructor in core java?..

Answer / rajib

Whenever we r using singleton class then we use constructor
as private.

Is This Answer Correct ?    38 Yes 6 No

what is the use of private constructor in core java?..

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

Post New Answer

More Core Java Interview Questions

What are implicit objects in java?

0 Answers  


What is the purpose of garbage collection in java? When is it used?

0 Answers  


What are the differences between string, stringbuffer and stringbuilder?

0 Answers  


extending thread class or implementing runnable interface. Which is better? : Java thread

0 Answers  


Explain java heap space and garbage collection?

0 Answers  






What is the default access specifier for variables and methods of a class?

0 Answers  


Why declare Main() inside the class in java ?

0 Answers   HCL,


Definition for connection pooling?

3 Answers  


Why strings in java are called as immutable?

0 Answers  


Is a copy constructor?

0 Answers  


How are this() and super() used with constructors in java programming?

0 Answers  


By what default value is an object reference declared as an instance variable?

1 Answers   Wipro,


Categories