wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC Question 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 Question" Watch "GC Question" New topic

GC Question

Lalit mishra
Ranch Hand

Joined: Sep 01, 2005
Posts: 100
for(int i =0;i<5;i++)
Demo d = new demo();
//line 1

How many object can be garbage collected at line 1
5 or 4
since even if d is out of scope at line 1
but it is still having reference to object demo??
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
5 objects will be garbage collected.

Reference is out of scope,meaning at line 1 no reference is for demo object.
I agree. Here's the link: http://aspose.com/file-tools
subject: GC Question
It's not a secret anymore!