单项选择题

Given
2. class Horse {
3. static String s = "";
4. void beBrisk() {s += "trot "; }
5. }
6. public class Andi extends Horse {
7. void beBrisk() { s += "tolt "; }
8. public static void main(String[] args) {
9. Horse x0 = new Horse();
10. Horse x1 = new Andi(); x1.beBrisk();
11. Andi x2 = (Andi)x1; x2.beBrisk();
12. Andi x3 = (Andi)x0; x3.beBrisk();
13. System.out.println(s);
14. } }
What is the result

A.tolt tolt tolt
B.trot tolt trot
C.trot tolt tolt
D.Compilation fails.
E.An exception is thrown at runtime.
题目列表

你可能感兴趣的试题

微信扫码免费搜题