• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

two Garbage Collection Quetion!!

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1:

After which line will the Object "hello" be free
for the garbage collection?
a) 9
b)10
c)8
d)11
e)None of above
//The answer is e. but I think the answer is b.
can you tell me the answer is right or not?

Q2:

Where will be the most chance of garbage collector
invoked?
a) After line no.9
b) After line no.10
c) After lint no.11
d) Garbage collector never invoked
e) After line no.4
//the answer is e, can you tell me why e is selected?
[Val added code tags and fixed some typos]
[ March 02, 2003: Message edited by: Valentin Crettaz ]
[ March 02, 2003: Message edited by: Valentin Crettaz ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread may help:
https://coderanch.com/t/241003/java-programmer-SCJP/certification/many-objects-eligible-garbage-collection
Thanks!
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Erico.
The second question is very bad worded, because the g.c. will only be invoked for certain when the free heap space is running out. Probably the mere execution of this program is not going to fill the heap.
The exam will ask somethig like: at what line the object pointed by variable v is first made eligible for g.c.? Well, they might be using a better English than me. :roll:
 
Erico Doon
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for all your help!
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic