试题详情
单项选择题 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();

  • D
  • 关注下方微信公众号,在线模考后查看

热门试题