1.

Which type of constructor can’t have a return type?(a) Default(b) Parameterized(c) Copy(d) Constructors don’t have a return typeThis question was posed to me in an international level competition.Asked question is from Types of Constructors in portion Constructors and Destructors of Object Oriented Programming

Answer»

Correct option is (d) Constructors don’t have a return TYPE

Explanation: Constructors don’t return any value. Those are special functions, WHOSE return type is not defined, not even void. This is so because the constructors are meant to initialize the members of CLASS and not to perform some task which can return some value to NEWLY CREATED object.



Discussion

No Comment Found

Related InterviewSolutions