what is the use of declaring constructor as private?
Answer Posted / ranganathkini
By declaring the class constructor as private, other classes
cannot create instances of the class.
This design is usually used in singleton patterns.
| Is This Answer Correct ? | 22 Yes | 2 No |
Post New Answer View All Answers
What is the purpose of a volatile variable?
What is a method type?
give an example for encapsulation?
What are constants?
How do you square a number in java?
how to create daemon thread in java?
Give differences between Quicksort & Mergesort. When should these sorts be used and what is their running time?
How to change value in arraylist java?
What is the this keyword?
What is the difference between && and & in java?
What methods are used in Servlet?Applet communication?
Why we do exception handling in java and how many types of exceptions are there?
What is concurrent hashmap and its features?
What is the functionality of the stub?
What is static method with example?