what is private constructor?what are the uses of writing
private constructor in our program?

Answer Posted / nandhakumar

We use private constructor in singleton class:it ve only one
instance,in this case we generally used to ve one static
method (getInstance()).While we cal this method first time
it use private constructor to create instance.next time this
method returns the existin instance..

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any sort function in java?

831


Why java uses the concept of the string literal?

744


What comes to mind when someone mentions a shallow copy in java?

876


Is hashset sorted in java?

855


What is the difference between comparison done by equals method and == operator?

767


What are thread safe functions?

713


1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?

4365


What are different access specifiers in java? Explain

822


What are sets in java?

720


Give the hierarchy of inputstream and outputstream classes.

806


What is scope & storage allocation of static, local and register variables? Explain with an example.

786


What is a programming object?

760


What is the length of a string?

728


Is set sorted in java?

690


How do you use parseint in java?

705