what is private constructor?what are the uses of writing
private constructor in our program?
Answer Posted / poonam suryawanshi
When we create a private constructor, we cannot create
object of the class directly from a client. So we will use
private constructor when we do not want instances of the
class to be created by any external client. Even it does not
allow us to inheritance of the class in another class.
Example Utility functions in project will have no instance
and be used without creating instance, as creating instances
of the class would be waste of time. When we create the
Private Constructor we have to make all the Variables and
Function as static.
Is This Answer Correct ? | 6 Yes | 3 No |
Post New Answer View All Answers
How can we make sure main() is the last thread to finish in java program?
What is the diffrence between inner class and nested class?
What is the main use of generics in java?
What about interrupt() method of thread class ?
What is the difference between synchronized and synchronized block?
What are data types in oop?
What is exception propagation?
What is serialversionuid?
Explain what are final variable in java?
What is public static?
Is singleton class immutable?
What’s the difference between unit, integration and functional testing?
What is a variable simple definition?
Is intellij better than eclipse?
What is the syntax and characteristics of a lambda expression?