多项选择题
现有:
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) { 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("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.编译错误 -
单项选择题
现有 class Beverage { Beverage () { System.out.print ("beverage "); } } class Beer extends Beverage { public static void main{string [] args) { Beer b = new Beer (14) ; } public int Beer(int x) { this () ; System.out.print ("beerl") ; } public Beer() { System.out.print("beer2 "); } } 结果是什么?()
A.beerl beverage
B.beer2 beverage
C.beverage beer2 beerl
D.编译失败
