阿摩線上測驗 登入

試題詳解

試卷:104年 - SCJP 51-100#99391 | 科目:OJCP(SCJP)

試卷資訊

試卷名稱:104年 - SCJP 51-100#99391

年份:104年

科目:OJCP(SCJP)

85. Given:
 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()); 
What is the result?
(A) peep
(B) bark
(C) meow
(D) Compilation fails.
(E) An exception is thrown at runtime.
正確答案:登入後查看