Originally posted by Shiva Mohan:
/*When the processing of line 3 begins, how many objects of type Q that were created at line 1 are eligible for garbage collection?
a. 0
b. 1
c. 9
d. 10
e. Indeterminate.
f. Compile-time error
g. Run-time error
h. None of the above
**/
The given explanation is
If method m2 causes a reference to be saved for each object that is passed in as an argument, then none of the objects are eligible for garbage collection when line 3 begins. Since we don't know what method m2 might be doing, we can not know if the objects are eligible for garbage collection.
But i am thinking,the compiler error will occur a line 2 since we didn't have the method m2(q1);.
Dear Shiva,
This is the most innocent answer I have seen ever in my life.
Well dear, it's not a whole question given in the paper, you must assume that there is a method
m2();. And if you are looking at compile error then why didn't you point out the main method missing and no class definations block is there.
Well, I think now you got the point, you have to assume about the method
m2(Q q1);.