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

garbage Collection

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello every body,
This question is from Mughal..
Select valid answers..
1. If object obj1 is accessible from object obj2 and object obj2 is accessible from obj1, then obj1 and obj2 are not eligible for garbage collection //false
2. IF an object obj1 can access an object obj2 that is eligible for garbage collection, then obj1 also eligible for garbage collection..//true
Can any body expalin.. these two statements with proper examples..
I am not getting real picture.. please explain with good examples..

Fast reply will be appreciated..
thanks in advance
regards,
Suresh
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. two objects may reference themselves but still be eligible for garbage collection because they may not be reachable from any active part of the program
2. if obj2 is eligible for garbage collection that means that obj2 is not reachable from any active part of the program. This also means that obj1 is not an "active part" of the program and thus must also be eligible for garbage collection.
Moreover, the following article explains the concepts. Read it carefully, it helped a lot in understanding garbage collection
Reference Objects and Garbage Collection
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
reply
    Bookmark Topic Watch Topic
  • New Topic