1.

If an object is passed by reference to a function then it must be returned by reference.(a) True(b) FalseThis question was addressed to me in an internship interview.My doubt is from Returning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer» RIGHT answer is (b) False

The best EXPLANATION: It is not compulsory to RETURN the object in the same way as it was passed. If the object is passed by reference then there is actually no NEED to return the object. Because the changes made inside the function will be visible on the original object of caller function also.


Discussion

No Comment Found

Related InterviewSolutions