wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes objects created on the heap and those eligible for gabage 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 "objects created on the heap and those eligible for gabage collection" Watch "objects created on the heap and those eligible for gabage collection" New topic
Author

objects created on the heap and those eligible for gabage collection

Harold Ndou
Ranch Hand

Joined: May 19, 2013
Posts: 34
class Dozens {
int[ ] dz = {1,2,3,4,5,6,7,8,9,10,11,12}
public class Eggs {
public static void main( String [] arg) {
Dozens [ ] da = new Dozens[3];
da[0] = new Dozens();
Dozens d = new Dozens();
da[1] = d;
d = null;
da [1] = null;
// do stuff
}
}
The answer is: five objets were created and two objects are elegible for gabage collection(C and F in the K & B study guide, chapter 3 self test question 10 on page 283

I have problem trying to understand the number of objects created within main () method, and those that are eligible for garbage collection. Can anyone assist me, i wil greatly appriciate it.
Arnab Sunny Rakshit
Greenhorn

Joined: Jun 07, 2013
Posts: 19

I tried to explain it in the Screenshot below.


[Thumbnail for Screenshot_2013-06-08-06-48-48.png]

Harold Ndou
Ranch Hand

Joined: May 19, 2013
Posts: 34
Thanks Arnub

I got it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: objects created on the heap and those eligible for gabage collection
 
Similar Threads
Garbage Colection
Garbage Collection
Garbage Collection - P274 Kathy Sierra
ch-assignment in kb ,need explanation of output:question 10
Garbage collection