Which statement is true?()A、 An anonymous inner class may be declared as final.B、 An anonymous inner class can be declared as private.C、 An anonymous inner class can implement multiple interfaces.D、 An anonymous inner class can access final variables in a

题目

Which statement is true?()

  • A、 An anonymous inner class may be declared as final.
  • B、 An anonymous inner class can be declared as private.
  • C、 An anonymous inner class can implement multiple interfaces.
  • D、 An anonymous inner class can access final variables in any enclosing scope.
  • E、 Construction of an instance of a static inner class requires an instance of the enclosing outer class.
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Static Nested Class 和 Inner Class的不同,说得越多越好


正确答案:
答:Static Nested Class是被声明为静态(static)的内部类,它可以不依赖于外部类实例被实例化。而通常的内部类需要在外部类实例化后才能实例化。

第2题:

Which statements concerning the correlation between the inner and outer instances of non-static inner classes are true?()  

  • A、Member variables of the outer instance are always accessible to inner instances, regardless of their      accessibility modifiers.
  • B、Member variables of the outer instance can never be referred to using only the variable name within     the inner instance.
  • C、More than one inner instance can be associated with the same outer instance.
  • D、All variables from the outer instance that should be accessible in the inner instance must be declared     final.
  • E、A class that is declared final cannot have any inner classes.

正确答案:A,C

第3题:

Given:Which statement is true about the class of an object that can reference the variable base? ()

A.It can be any class.

B.No class has access to base.

C.The class must belong to the geometry package.

D.The class must be a subclass of the class Hypotenuse.


参考答案:C

第4题:

Which statements can be inserted at the indicated position in the following code to make the program write 1 on the standard output when run?()  public class Q4a39 {  int a = 1;   int b = 1;   int c = 1;   class Inner {   int a = 2;  int get() {   int c = 3;   // insert statement here  return c;   }   }  Q4a39() {   Inner i = new Inner();   System.out.println(i.get());  }   public static void main(String args[]) {   new Q4a39();   }   }  

  • A、c = b;
  • B、c = this.a;
  • C、c = this.b;
  • D、c = Q4a39.this.a;
  • E、c = c;

正确答案:A,D

第5题:

Which two statements are true?()

  • A、 An inner class may be declared as static.
  • B、 An anonymous inner class can be declared as public.
  • C、 An anonymous inner class can be declared as private.
  • D、 An anonymous inner class can extend an abstract class.
  • E、 An anonymous inner class can be declared as protected.

正确答案:A,D

第6题:

以下程序的调试结果为?

public class Outer{

public String name = "Outer";

public static void main(String argv[]){

Inner i = new Inner();

i.showName();

}

private class Inner{

String name =new String("Inner");

void showName(){

System.out.println(name);

}

}

}

A.输出结果 Outer

B.输出结果 Inner

C.编译错误,因Inner类定义为私有访问

D.在创建Inner类实例的行出现编译错误


正确答案:D

第7题:

1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()  

  • A、 new Inner(); // At line 3
  • B、 new Inner(); // At line 8
  • C、 new o.Inner(); // At line 8
  • D、 new Outer.Inner(); // At line 8

正确答案:A

第8题:

Static Nested Class 和 Inner Class 的不同。


正确答案:

 

参见前面的什么是内部类的那道题

第9题:

package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?() 

  • A、 Compilation fails.
  • B、 An instance of the Inner class can be constructed with “new Outer.Inner()”.
  • C、 An instance of the Inner class cannot be constructed outside of package foo.
  • D、 An instance of the Inner class can be constructed only from within the Outer class.
  • E、 From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

正确答案:B

第10题:

Which thefollowingstatements about static inner classes is true?()

  • A、 An anonymous class can be declared as static.
  • B、 A static inner class cannot be a static member of the outer class.
  • C、 A static inner class does not require an instance of the enclosing class.
  • D、 Instance member of a static inner class can be referenced using the class name of the staticinner class.

正确答案:C

更多相关问题