可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

11. class Animal {&ens


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.printIn(cat.noise());  What is the result?() 

  • A peep
  • B bark
  • C meow
  • D Compilation fails.
  • E An exception is thrown at runtime.
参考答案
参考解析:
分类:SCJP程序员认证考试题库