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 do I run java on windows?
Can a set contain duplicates?
Does printwriter create a file?
What is oops in java?
What is the function of compareto in java?
What is boolean strategy?
How large is a boolean?
How to sort elements in a parallel array in java?
What is boolean query?
Which is easier netbeans or eclipse?
What is the difference between post and put?
What is meant by oops concept in java?
Explain about automatic type conversion in java?
what state does a thread enter when it terminates its processing? : Java thread
Explain the difference between runnable and callable interface in java?