public class Parent{ public void method(){ System.out.println("parent"); } public static void smethod(){ Sysyem.out.println("static parent"); } } public class Child extends parent{ public void method(){ System.out.println("child"); } public static void smethod(){ Sysyem.out.println("static child"); } } public class test{ public static void print(String [] args){ Child c=new Child(); Parent p=(Parent)c; p.method(); p.smethod(); } 答案是:child,static parent
|