1.

If constructors of a class are defined in private access, then __________(a) The class can’t be inherited(b) The class can be inherited(c) Instance can be created only in another class(d) Instance can be created anywhere in the programI have been asked this question in an online interview.The origin of the question is Types of Constructors in portion Constructors and Destructors of Object Oriented Programming

Answer»

Right choice is (a) The CLASS can’t be inherited

The best I can explain: If the CONSTRUCTORS are defined in private access, then the class can’t be inherited by other classes. This is useful when the class contains static members only. The INSTANCES can NEVER be CREATED.



Discussion

No Comment Found

Related InterviewSolutions