1.

It is necessary to return the object if it was passed by reference to a function.(a) Yes, since the object must be same in caller function(b) Yes, since the caller function needs to reflect the changes(c) No, the changes are made automatically(d) No, the changes are made explicitlyThis question was addressed to me in an internship interview.My query is from Passing and Returning Object with Functions topic in division Object of Object Oriented Programming

Answer»

The correct option is (c) No, the changes are MADE automatically

The explanation: Having the address being PASSED to the function, the changes are automatically made to the main function. In all the cases if the address is being used, the same memory LOCATION will be UPDATED with NEW values.



Discussion

No Comment Found

Related InterviewSolutions