Interviews2 answers
what is a private constructor for a class ? what is its need ?
2 Answers
When a class is containing all the members static, we no need of creating an object of that class. We can directly access members using dot(.) operator with that class. So, to prevent the class being created an object, we use private constructor.
Dumkal KomPosted Apr 12, 2015, 7:37 PM EDT
When a class is containing all the members static, we no need of creating an object of that class. We can directly access members using dot(.) operator with that class. So, to prevent the class being created an object, we use private constructor.
Dumkal KomPosted Apr 12, 2015, 7:37 PM EDT