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


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

Garbage collection

Rajni Patel
Ranch Hand

Joined: Sep 03, 2009
Posts: 84
topic : Garbage collection

could you explain me what is result and how?

class Dozens{
int[] dz = {1,2,3,4,5,6,7,8,9,10,11,12};
}
public class Eggs{
public static void main(String[] args){
dozens [] da = new Dozebs[3];
da[0] = new Dozens();
Dozens d = new Dozens;
da[1] = d;
d = null;
da[1] = null;
// do stuff
}
}

how many objects will create and how many objects are eligible for garbage collection when line 14 is reached?
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Well How many do you think is eligible? Also this question is discussed many times in the forums. Please search it.


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

Welcome to JavaRanch.

If you search for "Dozens", you will find a few older topics in which the same question was discussed, for example:

http://www.coderanch.com/t/457125/Programmer-Certification-SCJP/certification/Garbage-collection
http://www.coderanch.com/t/456750/Programmer-Certification-SCJP/certification/Number-objects-Array
http://www.coderanch.com/t/454321/Programmer-Certification-SCJP/certification/capitulo-kathy-sierra-book

One more important thing: When you copy a question from a book, mock exam or other source, please quote your sources - tell us where you copied it from. That's required on JavaRanch.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection