interface Itfce { public void x(); } abstract class Abs { public static void f1() { System.out.println("Static 1 "); } public abstract void a1(); public void a2() { f1(); } } class C1 extends Abs implements Itfce{ @Override public void a1() { // Class 'C1' must either be declared abstract or implement abstract method 'a1()' in 'Abs' System.out.println("必须实现 抽象父类的 抽象方法 a1()" ); } @Override public void x() { //Class 'C1' must either be declared abstract or implement abstract method 'x()' in 'Itfce' System.out.println("必须实现接口的所有方法 x()"); } } public class Interface_test { public static void main(String[] args) { C1 c = new C1(); c.a1(); c.x(); c.a2(); //抽象类可以实现方法 a2 } }
https://blog.csdn.net/zhangquan2015/article/details/82808399
https://www.runoob.com/java/java-abstraction.html