给出以下代码,请问该程序的运行结果是什么?如有问题,请说明原因。 abstract class SuperEx { String s = "父类成员变量"; public void method(); } class SubEx extends SuperEx { String s = "子类成员变量"; public void method(){ System.out.println("SubMethod"); } } class Demo { public static void main (String[] args) { SuperEx sup = getInstance(); System.out.println(sup.s); function( sup ); } public static SuperEx getInstance(){ return new SubEx (); } public static void function (SuperEx sup) { sup.method(); } }
|