题目内容

给出以下代码:11. class Animal { public String noise() {return "peep"; } }12. class Dog extends Animal {13. public String noise() { return "bark"; }14. }15. class Cat extends Animal {16. public String noise() { return "meow"; }17. } ...30. Animal animal = new Dog();31. Cat cat = (Cat)animal;32. System.out.println(cat.noise());请问程序的执行结果是什么?

A.peep
B.bark
C.meow
D.编译失败
E.执行时发生ClassCastException

查看答案
更多问题

为了区分重载多态中同名的不同方法,要求()。

A. 采用不同的参数列表
B. 返回值类型不同
C. 调用时用类名或对象名做前缀
D. 参数名不同

定义主类的类头时可以使用的访问修饰符是()。

A.private
B.protected
C.public
D.private protected

以下代码:11. public interface Status {12. /* 这里可以填什么 */ int MY_VALUE = 10;13. }以下选三项().

A.final
B.static
C.native
D.public
E.private
F.abstract
G.protected

阅读以下程序:1.class Super {2. private int a;3. protected Super(int a) { this.a = a; }4. } ...11. class Sub extends Super {12. public Sub(int a) { super(a); }13. public Sub() { this.a = 5; }14. }以下那两项可以让上述程序通过编译?

A.Change line 2 to:public int a;
B.Change line 2 to:protected int a;
C.Change line 13 to:public Sub() { this(5); }
D.Change line 13 to:public Sub() { super(5); }
E.Change line 13 to:public Sub() { super(a); }

答案查题题库