File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection
 
Similar Threads
Garbage Colection
garbage collection
Garbage collection problem
Question on garbage collection from Kathy Sierra.
ch-assignment in kb ,need explanation of output:question 10