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

Why do we need public static void main(String args[]) method in Java...?

1 Answers  


If two threads call a static method at the same point of time, what will happen?

3 Answers   KPIT,


Why put method is used?

0 Answers  


what are the oops concept in java explain with real time examples

24 Answers   Accenture, Bosch, Consummate Technologies, CTS, Current Technologies, iNautix, Infosys, Kekran Mekran, QA InfoTech, RTRT, SofTech, Tech Mahindra, Thorogood, Timios, Wipro,


What is purpose of keyword void?

0 Answers  






What is compile time polymorphism?

20 Answers   CTS, Elementus Technologies, Oracle,


How do you test a method for an exception using junit?

0 Answers  


Why java Don't Support Multiple interitence

8 Answers   ABC, Exilant, IBM,


Are global variables initialized to zero?

0 Answers  


A class can be a subclass of itself?

2 Answers   Genesis,


Does A Class Inherit The Constructors Of Its Superclass?

0 Answers   Wipro,


Are there structures in java?

0 Answers  


Categories