black

SCJP程序员认证考试

登录

单项选择题

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();

相关考题

单项选择题 1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for garbage collection?()

多项选择题 Whichtwocauseacompilererror?()

单项选择题 public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()

All Rights Reserved 版权所有©财会考试题库(ckkao.com)

备案号:湘ICP备2022003000号-2