网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

interface Animal {  void soundOff();  }  class Elephant implements Animal {  public void soundOff() {  System.out.println(“Trumpet”);  }  }  class Lion implements Animal {  public void soundOff() { System.out.println(“Roar”);  }  }  class Alpha1 {  static Animal get( String choice ) {  if ( choice.equalsIgnoreCase( “meat eater” )) {  return new Lion();  } else {  return new Elephant();  }  }  }  Which compiles?()  

  • A、 new Animal().soundOff();
  • B、 Elephant e = new Alpha1();
  • C、 Lion 1 = Alpha.get(“meat eater”);
  • D、 new Alpha1().get(“veggie”).soundOff();

参考答案

更多 “ interface Animal {  void soundOff();  }  class Elephant implements Animal {  public void soundOff() {  System.out.println(“Trumpet”);  }  }  class Lion implements Animal {  public void soundOff() { System.out.println(“Roar”);  }  }  class Alpha1 {  static Animal get( String choice ) {  if ( choice.equalsIgnoreCase( “meat eater” )) {  return new Lion();  } else {  return new Elephant();  }  }  }  Which compiles?()  A、 new Animal().soundOff();B、 Elephant e = new Alpha1();C、 Lion 1 = Alpha.get(“meat eater”);D、 new Alpha1().get(“veggie”).soundOff();” 相关考题
考题 静态变量就是类变量,系统只为每个类分配一套类变量,所有的实例变量共享一套类变量。

考题 11. public void genNumbers() {  12. ArrayList numbers = new ArrayList();  13. for (int i=0; i10; i++) {  14. int value = i * ((int) Math.random());  15. Integer intObj = new Integer(value);  16. numbers.add(intObj);  17. }  18. System.out.println(numbers);  19. }  Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?() A、 Line 16B、 Line 17C、 Line 18D、 Line 19E、 The object is NOT a candidate for garbage collection.

考题 An object is()A、what classes are instantiated from.B、an instance of a class.C、a blueprint for creating concrete realization of abstractions.D、a reference to an attribute.E、a variable.

考题 接口如何实现()A、利用一个继承自接口的类来实现B、利用类来实现,在类定义部分用"implements"关键字表示这个类所实现的接口C、利用与接口同名的类来实现D、利用一系列全局函数来实现

考题 从运行层面上来看,从四个选项选出不同的一个()。A、JAVAB、PythonC、objectCD、C#

考题 int x = 3;  int y = 1;  if (x = y) {  System.out.println(“x = “ + x);  }  What is the result? ()A、x=1B、x=3C、Compilationensp;fails.D、Theensp;codeensp;runsensp;withensp;noensp;output.ensp;E、Anensp;exceptionensp;isensp;thrownensp;atensp;runtime.

考题 Map接口中的方法EntrySet()返回的内容是哪项?() A、 键的集合B、 值的集合C、 集合的大小D、 键值映射的集合