1.

How to make more than one object refer to the same object?(a) Initialize it to null(b) Initialize the object with another at declaration(c) Use constructor to create new object(d) Assign the address directlyThe question was asked at a job interview.I'd like to ask this question from Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right OPTION is (b) Initialize the object with another at declaration

Easiest EXPLANATION - The object must get initialized with another object at time of declaration only. We don’t have to CREATE a new object we just have to get name of new object because there after same address will be REFERRED.



Discussion

No Comment Found

Related InterviewSolutions