Which are true about the objects created within main(), and eligible for garbage collection when line 14 is reached? : Questions « Utility Classes « SCJP






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


   A.      Three objects were created
   B.      Four objects were created
   C.      Five objects were created
   D.      Zero objects are eligible for GC
   E.      One object is eligible for GC
   F.      Two objects are eligible for GC
   G.      Three objects are eligible for GC








8.30.Questions
8.30.1.What happens when you try to compile and run code containing the following lines:
8.30.2.Answer: Float + String
8.30.3.Which of the following Collections classes can return object references in the order of addition?
8.30.4.Answer: collection and order
8.30.5.Which of the following interfaces in the java.util package does java.util.Hashtable implement?
8.30.6.Answer: Hashtable and interface
8.30.7.What does Math.random() method return?
8.30.8.Answer: return value from Math.random()
8.30.9.What kind of stream is the System.out object?
8.30.10.Answer: System.out stream
8.30.11.When // XXX is reached, how many objects are eligible for GC?
8.30.12.Answer: garbage collection
8.30.13.What is the result(overloaded and var-args methods)?
8.30.14.Answer: overloaded and var-args methods
8.30.15.What is the result(array dimension)?
8.30.16.Answer: array dimension
8.30.17.What is the result(constructor)?
8.30.18.Answer: constructor
8.30.19.What is the result(final class reference)?
8.30.20.Answer: final class reference
8.30.21.What is the result(hierarchy and static init blocks)?
8.30.22.Answer: hierarchy and static init blocks
8.30.23.What is the output(enum)?
8.30.24.Answer: enum
8.30.25.What is the result(static variable)?
8.30.26.Answer: static variable
8.30.27.What is the result(autobox and widen)?
8.30.28.Answer: autobox and widen
8.30.29.Which are true about the objects created within main(), and eligible for garbage collection when line 14 is reached?
8.30.30.Answer: garbage collection and array objects
8.30.31.When 'do stuff' is reached, how many objects will be eligible for garbage collection?
8.30.32.Answer: ready for garbage collection
8.30.33.What is the result(class instance variables)?
8.30.34.Answer: class instance variables
8.30.35.What is the result(pre-increment operators)?
8.30.36.Answer: pre-increment operators