单项选择题
A.抽象类中一定含有抽象方法 B.抽象类的声明必须包含abstract关键字 C.抽象类既能被实例化也能被继承 D.抽象类中不能有构造方法
现有: class HorseRadish { //insert code here prot...
多项选择题
现有: class HorseRadish { //insert code here protected HorseRadish (int x) { System.out.println ("bok choy"); } } class Wasabi extends HorseRadish { public static void main (String [] args){ Wasabi w- new Wasabi(); } } 分别插入到第2行,哪两项允许代码编译并产生”bok choy”输出结果()
A. protected HorseRadish() {this (42);} B. protected HorseRadish() {} C. //just a comment D. protected HorseRadish() { new HorseRadish (42);}
现有: 1.class SuperFoo{ 2.SuperFoo doStuff (int x) { ...
现有: 1.class SuperFoo{ 2.SuperFoo doStuff (int x) { 3.return new SuperFoo(); 4. } 5. } 6. 7. class Foo extends SuperFoo { 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
现有: class Bird { void talk() { System.out.print("chir...
现有: class Bird { void talk() { System.out.print("chirp "); } } class Parrot2 extends Bird { protected void talk() { System.out.print("hello "); public static void main(String [] args) { Bird [] birds = {new Bird(), new Parrot2 () }; for( Bird b : birds) b.talk () ; } } 结果是什么 ?()
A. chirp chirp B. hello hello C. chirp hello D.编译错误