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
Why is it important to initialize a variable?
'A class is a template for an object' explain this statement.
How to perform quicksort in java?
What are measurable parameters?
What is the destroy method?
What is meant by object oriented programming – oop?
What are the access modifiers available in java?
How do you check if a string is lexicographically in java?
What is variable and its types?
Explain the difference between jvm and jre?
What is a “stateless” protocol ?
What does java stand for?
Which is better list or arraylist in java?
How many types of keywords are there?
What are controls and their different types in awt?