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 is the difference between Java and C++?

1 Answers   Integreon, TCS, ZS Associates,


Difference between string, stringbuffer and stringbuilder?

1 Answers  


Is space a character in java?

1 Answers  


What is public static?

1 Answers  


What is getclass () getname () in java?

1 Answers  


what is Assertion?

4 Answers   Wipro,


Diff between C++ and java?

9 Answers   TCS,


What is java used for on a computer?

1 Answers  


java program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

7 Answers   HCL, Wipro,


What is the base class of all exception classes in java?

1 Answers  


How would you format a date in java? I.e. In the ddmmyyy format?

1 Answers  


How do you create a null object?

1 Answers  


Categories