• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection dan's question

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



/*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);.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are meant to assume that method m2(Q q) exists but you do not know what it does.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);.
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok�......

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.



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

Is true.Can anyone please explain the above sentence for me.
[ September 29, 2006: Message edited by: Shiva Mohan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic