public class Test extends Base
{
Test()
{
draw();
System.out.println("test end");
}
public void draw()
{
System.out.println("test.draw " );
}
public static void main(String[] args)
{
Test t1 = new Test();
}
}
=======执行结果==============================
F:\java\javaproj>java Test
test.draw
base end
test.draw
test end
=============================================
为什么父类构造函数中的draw()方法,调用了子类的draw()方法? ------解决方案-------------------- 虚拟机在执行构造方法之前把子类的draw方法覆盖了父类的,如有需要就得特别指出 ------解决方案--------------------