• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Garbage Collection

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys
Is the following statement regarding Garbage Collections true?
When Garbage Collection runs it releases the memory allocated by an object ?
My answer to it is False
because when the finalize method if present is executed which in turn my reconstruct an object.
Plz guide me on this question
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The answer should be true, Garbage Collection runs after finalize method.
Please correct me if i am wrong
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Dian He.
The answer shold be true.
Finalization resurrecting an object should be considered as a special case I feel;
HTH
tvs sundaram.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the answer should be false since the memory will not be released when the GC runs if the object is still referenced by other live object.
Correct me if i am wrong.
Guoqiao

Originally posted by Kaushik Badiyani:
Hi Guys
Is the following statement regarding Garbage Collections true?
When Garbage Collection runs it releases the memory allocated by an object ?
My answer to it is False
because when the finalize method if present is executed which in turn my reconstruct an object.
Plz guide me on this question


 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
The statement is a generalization of gc behaviour and, as such, is not very clear. It's implying that:
The garbage collector's job is to release memory allocated to objects which are no longer being referenced.
But not stating it clearly so it can be 'true' or 'false' depending on your interpretation. Questions on the real exam will not be so ambiguous.
Hope that helps.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Attractive, successful people love this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic