packageabstract_;publicclass main {publicstaticvoidmain(String[] args){a a =newa();a.show();System.out.println("------------------------------------");b b =newb();b.show();}}abstractclass shared {publicabstractvoidtool(int a,int b);// 抽象方法不可以有方法体publicvoidshow(){System.out.println("你进入了抽象类的show方法:开始执行");tool(2,3);System.out.println("你退出了抽象类的show方法:执行结束");}}class a extends shared {publicvoidtool(int a,int b){System.out.println("a + b = "+(a + b));}}class b extends shared {publicvoidtool(int a,int b){System.out.println("a * b = "+(a * b));}}//输出结果
你进入了抽象类的show方法:开始执行
a + b =5
你退出了抽象类的show方法:执行结束
------------------------------------
你进入了抽象类的show方法:开始执行
a * b =6
你退出了抽象类的show方法:执行结束