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
Which class contains a method: cloneable or object?
How many types of the indexof method are there for strings?
Can you declare the main method as final?
What things should be kept in mind while creating your own exceptions in java?
What is a “stateless” protocol ?
What do you mean by light weight and heavy weight components?
Differentiate storage classes on the basis of their scope?
What is basic syntax?
What access modifiers can be used for methods?
What is a conditional equation?
Is string pool garbage collected?
What is return keyword in java?
How do you use compareto?
Is age a discrete variable?
What is a parameter example?