• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Garbage collection dan's question

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are meant to assume that method m2(Q q) exists but you do not know what it does.
 
Ranch Hand
Posts: 1249
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic