1.

Which returning an object, we can use ____________(a) Default constructor(b) Zero argument constructor(c) Parameterized constructor(d) Copy constructorI have been asked this question in an interview.Question is taken from Copy Constructor topic in portion Constructors and Destructors of Object Oriented Programming

Answer» RIGHT ANSWER is (d) Copy constructor

The EXPLANATION: While RETURNING an object we can USE the copy constructor. When we assign the return value to another object of same class then this copy constructor will be used. And all the members will be assigned the same values as that of the object being returned.


Discussion

No Comment Found

Related InterviewSolutions