Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection? 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 "Garbage collection?" Watch "Garbage collection?" New topic

Garbage collection?

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252

here i thought the answer to be 2..

but its not ...can anyone explain me when does the object gets garbage collected exactly??


Thanks & Regards<br /> <br />-Srikanth
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Never in that method . Answer 'c' because , eventhough 'b' is set to null
the reference variable c points to this object and it is returned to the calling place.
[ September 22, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Lalitha Gottumukkula
Ranch Hand

Joined: May 24, 2005
Posts: 45
Because it is having direct reference (c), it is never garbage collected.
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
yes srinivas,

got it ..thanks for your help
I agree. Here's the link:
subject: Garbage collection?
It's not a secret anymore!