A..java B..txt C.以上都不是 D..class E..c
1.class SuperFo{ 2. SuperFo doStuff(int x){ 3.return new SuperFo() 4.} 5.} 6. 7.class Foo extends SuperFo{ 8.//insert code here 9.} 和四個聲明: Foo doStuff(int x){return new Foo();} Foo doStuff(int x){return new SuperFoo();} SuperFoo doStuff(int x){return new foo();} SuperFoo doStuff(int y){return new SuperFoo();} 分別插入到第8行,有幾個可以通過編譯 ()
A.1 B.2 C.3 D.4 E.5
class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 結(jié)果為:
A.運(yùn)行時異常被輸出 B.第7行出現(xiàn)一個錯誤,編譯失敗 C.第8行出現(xiàn)一個錯誤,編譯失敗 D.hi hi hi E.hi hawdy doude