abstract class Father{ abstract void show(); } class Son extends Father { public void show(){ System.out.println("I am son."); } } public class start { public static void main(String[] args) { Father son=new Son(); son.show(); } }
输出结果为:
I am son.
*******************************************************************************************************************************
class Father{ public void show(){ System.out.println("I am father."); } } class Son extends Father { public void show(){ System.out.println("I am son."); } } public class start { public static void main(String[] args) { Father son=new Son(); son.show(); } }
输出结果为:
I am son.
*******************************************************************************************************************************
class Father{ } class Son extends Father { public void show(){ System.out.println("I am son."); } } public class start { public static void main(String[] args) { Father son=new Son(); son.show(); } }
编译错误。