1.

Which among the following is correct?(a) Individual data members can’t be returned(b) Individual data members can be returned(c) Individual member functions can be returned from another function(d) Individual data members can only be passed by referenceI got this question in an interview for job.This key question is from Returning Objects topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right answer is (B) INDIVIDUAL data members can be returned

Easiest EXPLANATION - It is not MANDATORY to return the whole object. Instead we can return a specific data member value. But the return type given must match with the data type of the data being returned.



Discussion

No Comment Found

Related InterviewSolutions