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
What is main method?
What is the difference between pass by reference and pass by pointer?
What is double checked locking in singleton?
Is singleton class thread safe?
Which sorting is best in java?
What is the difference between a checked and an unchecked exception?
Can we create an object of private class?
Should database connections be singleton?
What state does a thread enter when it terminates its processing in java programming?
What is executor memory?
What is string manipulation?
How do I type unicode?
Explain about object oriented programming and its features?
What two classes are used to read data only?
Is string a wrapper class?