This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC" Watch "GC" New topic
Author

GC

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.
HTH
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GC
 
Similar Threads
Garbage collection?
garbage collection
GC
GC ??
Unfair Question on JQ