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 java a digit method?

520


Which number is denoted by leading zero in java?

815


What is hashtable and explain features of hashtable?

568


Can a abstract class be defined without any abstract methods?

565


What is a lambda expression ? What's its use ?

567






Can list be null in java?

581


What is nested loop? What is dangling else condition in it?

575


These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }

603


Explain about main() method in java ?

589


What are reference variables in java?

600


What are bind parameters?

555


What is return null in java?

514


Can substring create new object?

564


What do you understand by java?

567


What is exception in java?

572