Review Questions


graphics/rq_icon.gif
7.6

Which statement is true?

Select the one correct answer.

  1. Non-static member classes must have either default or public accessibility.

  2. All nested classes can declare static member classes.

  3. Methods in all nested classes can be declared static .

  4. All nested classes can be declared static .

  5. Static member classes can contain non-static methods.

7.7

Given the declaration

 interface IntHolder { int getInt(); } 

which of the following methods are valid?

 //----(1)----     IntHolder makeIntHolder(int i) {         return new IntHolder() {             public int getInt() { return i; }         };     } //----(2)----     IntHolder makeIntHolder(final int i) {         return new IntHolder {             public int getInt() { return i; }         };     } //----(3)----     IntHolder makeIntHolder(int i) {         class MyIH implements IntHolder {             public int getInt() { return i; }         }         return new MyIH();     } //----(4)----     IntHolder makeIntHolder(final int i) {         class MyIH implements IntHolder {             public int getInt() { return i; }         }         return new MyIH();     } //----(5)----     IntHolder makeIntHolder(int i) {         return new MyIH(i);     }     static class MyIH implements IntHolder {         final int j;         MyIH(int i) { j = i; }         public int getInt() { return j; }     } 

Select the two correct answers.

  1. The method labeled (1).

  2. The method labeled (2).

  3. The method labeled (3).

  4. The method labeled (4).

  5. The method labeled (5).

7.8

Which statements are true?

Select the two correct answers.

  1. No other static members , except final static fields, can be declared within a non-static member class.

  2. If a non-static member class is nested within a class named Outer , then methods within the non-static member class must use the prefix Outer.this to access the members of the class Outer .

  3. All fields in any nested class must be declared final .

  4. Anonymous classes cannot have constructors.

  5. If objRef is an instance of any nested class within the class Outer , then the expression (objRef instanceof Outer) will evaluate to true .

7.9

Which statement is true?

Select the one correct answer.

  1. Top-level classes can be declared static .

  2. Classes declared as members of top-level classes can be declared static .

  3. Local classes can be declared static .

  4. Anonymous classes can be declared static .

  5. No classes can be declared static .



A Programmer[ap]s Guide to Java Certification
A Programmer[ap]s Guide to Java Certification
ISBN: 201596148
EAN: N/A
Year: 2003
Pages: 284

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net