• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Query on GC from KAM book

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,
I'm referring to one of the questions from Khalid Mughal's book, the question goes like this.
Which statements describe guaranteed behaviour of the garbage collection and finalization mechanisms?
[Select all valid answers]
1> Objects will not be destroyed until they have no references to them. (In short if there is a reference the object wouldn't be garbage collected, i guess)
2> The finalize method will never be called more than once on an object.
3> An object eligible for garbage collection will eventually be destroyed be the garbage collector.
4> If object A became eligible for garbage collection before object B, then object A will be destroyed before object B.
5> An object once eligible for garbage collection can never become accessible from an active part of the program.

I think the correct answers are: 1 & 2
But he's given only 2 to be correct.
Can anyone please tell me why is the first answer wrong.
Thanx in advance.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear shaibaz
the answer to your que is given in the book itself. I guess that even if you are having circular reference to object then it can be destroyed if both the objects are having no other reference. thats why ans 1> is wrong.
Hope this clarifies.
 
Shaibaz Gadhwala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rakesh,
Could you clarify the things with an example....
thanks in advance
reply
    Bookmark Topic Watch Topic
  • New Topic