两个简单的问题!!!!!
程序代码:
package hehe_1; public class MethodOverride { public static void main(String[] args) { SubClass s = new SubClass(); s.fun(); } } class SuperClass { int i = 1; public void fun() { System.out.println("super"); System.out.println("父类的i=" + i); } } class SubClass extends SuperClass { int i = 2; public void fun() { System.out.println("Sub"); System.out.println("子类的i=" + i); super.fun(); } }
问题一:为什么先执行子类,而不是父类呢?
问题二:子类的super有什么作用?