my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Have a Question on this Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Have a Question on this Question" Watch "Have a Question on this Question" New topic

Have a Question on this Question

Harish Tam
Ranch Hand

Joined: Feb 17, 2005
Posts: 71

was reading a book it had a question like this

when //do stuff is reached how many objects are eligible for GC
and the answer is 2 c1 object and a short object in c1

my Question over here is as per the above code should c3 be also eligible for GC ?

SCJP 1.4, SCWCD 1.4
Matthew Brown

Joined: Apr 06, 2010
Posts: 4537

Only objects are eligible for garbage collection, not variables. And c3 is only ever set to null - there is no object created that can be garbage collected.
subject: Have a Question on this Question
It's not a secret anymore!