What is the result(constructor)? : Questions « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Questions 
8.30.17.What is the result(constructor)?
public class MainClass {
  MainClass() {
  }

  MainClass(MainClass m) {
    m1 = m;
  }

  MainClass m1;

  public static void main(String[] args) {
    MainClass m2 = new MainClass();
    MainClass m3 = new MainClass(m2);
    m3.go();
    MainClass m4 = m3.m1;
    m4.go();
    MainClass m5 = m2.m1;
    m5.go();
  }

  void go() {
    System.out.print("hi ");
  }
}
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.