Answer: nested class and outter class : Questions « Object Oriented « SCJP






A



class BaseClass {
  BaseClass() {
  }

  public class NestedClass {
    NestedClass() {
    }

  }

}

public class MainClass {
  public static void main(String[] argv) {

    BaseClass.NestedClass nbc = new BaseClass().new NestedClass();
    System.out.println();
  }
}








6.15.Questions
6.15.1.Java garbage collector executes as a low-priority, background thread(True/False).
6.15.2.Answer: garbage collection thread
6.15.3.Java garbage collector keeps track of which objects are reachable and unreachable(True/False).
6.15.4.Answer: garbage collection and reachable and unreachable objects
6.15.5.Java garbage collector can be directed to garbage collect specific objects(True/False).
6.15.6.Answer: garbage collection and specific objects
6.15.7.An object's finalize() method can be invoked multiple times by the garbage collector(True/False).
6.15.8.Answer: calling to finalize method
6.15.9.If an object's finalize() method is invoked, the object will be garbage collected(True/False).
6.15.10.Answer: finalize method and garbage collection
6.15.11.If the object has been garbage collected, its finalize() method has been invoked(True/False).
6.15.12.Answer: calling to finalize method and garbage collection
6.15.13.An object's finalize() method must perform cleanup operations(True/False).
6.15.14.Answer: finalize method and cleanup
6.15.15.The inner class will have access only to static variables in the enclosing class(True/False).
6.15.16.Answer: inner class and static variables
6.15.17.The inner class can use any variables declared in the method(True/False).
6.15.18.Answer: inner class and local variable
6.15.19.The inner class can use only local variables that are declared final(True/False).
6.15.20.Answer: final local variable and inner class
6.15.21.The inner class can use only local variables that are declared static(True/False).
6.15.22.Answer: static local variable and inner class
6.15.23.Which of the following code fragments shows the correct way to declare and initialize a reference to a NestedClass object from outside NormalClass?
6.15.24.Answer: static nested class definition
6.15.25.Which of the following code fragments shows the correct way to declare and initialize a reference to a NestedClass object from outside BaseClass?
6.15.26.Answer: nested class and outter class
6.15.27.Which variables would be able to use in place of XX?
6.15.28.Answers: varible reference for inner class
6.15.29.An inner class can have the same name as its enclosing class(True/False).
6.15.30.Answer: naming the inner class
6.15.31.An instance of a nonstatic inner class always has an associated instance of the enclosing class(True/False).
6.15.32.Answer: non-static inner class
6.15.33.What is the output when compiling and running the following code?
6.15.34.Answer: overloading method call
6.15.35.What happens when you try to compile and run the following code?
6.15.36.Answer: Compare Integer and Long
6.15.37.Is the following code a proper way to override?
6.15.38.Answer: how to override
6.15.39.What is the output when compiling the following code
6.15.40.Answer: overriding method and return value
6.15.41.What happens when you try to compile another class that includes the following method?
6.15.42.Answer: abstract class