1.

Which among the following is not a necessary condition for constructors?(a) Its name must be same as that of class(b) It must not have any return type(c) It must contain a definition body(d) It can contains argumentsI have been asked this question in an online interview.This intriguing question comes from Constructors topic in section Constructors and Destructors of Object Oriented Programming

Answer» RIGHT option is (c) It must CONTAIN a DEFINITION body

The explanation is: Constructors are predefined implicitly, even if the programmer doesn’t define any of them. Even if the programmer declares a CONSTRUCTOR, it’s not necessary that it must contain some definition.


Discussion

No Comment Found

Related InterviewSolutions