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 are recursive functions?
What is JVM and is it platform independent?
State differences between C and Java?
What is the purpose of static keyword in java?
Explain the polymorphism principle?
Can singleton class be inherited in java?
What is a return in java?
Can a class be final?
What do the thread?class methods run() and start() do?
Can we use a switch statement with strings?
What is mean by encoding?
How do you clear an arraylist in java?
Can a class have an interface?
What is the tradeoff between using an unordered array versus an ordered array?
How many types of array are there?