Advertisement

假定Base b = new Derived() ;

阅读量:

Java面试题18 牛客 假设Base b = new Derived(); 在执行b.methodOne()后,最终的输出结果会是怎样的?

|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28|public class Base { ``public void methodOne() ``{ ``System.out.print(``"A"``); ``methodTwo(); ``} ``public void methodTwo() ``{ ``System.out.print(``"B"``); ``} } public class Derived extends Base { ``public void methodOne() ``{ ``super.methodOne(); ``System.out.print(``"C"``); ``} ``public void methodTwo() ``{ ``super.methodTwo(); ``System.out.print(``"D"

全部评论 (0)

还没有任何评论哟~