1.

Is it possible that an object of is passed to a function, and the function also have an object of same name?(a) No, Duplicate declaration is not allowed(b) No, 2 objects will be created(c) Yes, Scopes are different(d) Yes, life span is differentI have been asked this question in my homework.This interesting question is from Passing and Returning Object with Functions in section Object of Object Oriented Programming

Answer»

Correct CHOICE is (a) No, DUPLICATE declaration is not allowed

Easy explanation - There can’t be more than one VARIABLE or object with the same NAME in same scope. The scope is same, since the object is passed, it becomes local to FUNCTION and hence function can’t have one more object of same name.



Discussion

No Comment Found

Related InterviewSolutions