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

Answer Posted / christian

a common use for a private constructor is to implement the
singletton pattern, which uses a public member variable of
the same type of the class which is defined. A public
getInstance() method uses this private constructor

Is This Answer Correct ?    13 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is considered an anti pattern?

706


Give a brief description of java socket programming?

739


Explain the use of volatile field modifier?

845


What happens if an exception is throws from an object's destructor?

793


What is the use of coding?

725


How define set in java?

764


What is difference between fail-fast and fail-safe?

842


What is use of static method?

750


Explain the pointers in Java?

809


What is the difference between menuitem and checkboxmenu item?

1063


What is private static class in java?

744


What is difference between length and length() method in java ?

764


What are the differences between heap and stack memory in java?

762


Is char a method in java?

738


How do you calculate roots in java?

766