File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC" Watch "GC" New topic


Thiru Thangavelu
Ranch Hand

Joined: Aug 29, 2001
Posts: 219
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?

Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Because the object pointed by b is also pointed by c, and c is returned.

SCJP2. Please Indent your code using UBB Code
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
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.
I agree. Here's the link:
subject: GC
It's not a secret anymore!