Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC

 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the answer is after //4. But the answer given is never GC. why?
After which line will the object created at line XXX be eligible for garbage collection?
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the object pointed by b is also pointed by c, and c is returned.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getObject() is returning a reference to the object you created at line XXX. Since the object is still referenced, it is not yet eligible for garbage collection.
HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic