aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC Question" Watch "GC Question" New topic
Author

GC Question

Lalit mishra
Ranch Hand

Joined: Sep 01, 2005
Posts: 99
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