比较项目 | 接口 | 抽象类 |
方法是否有实体 | 无 | 抽象方法无实体,非抽象方法可以有实体 |
方法开闭性 | public | public,protected,private |
重载方法的开闭性 | public | 必须与父类相等或更开放,如父类为protected,子类必须protectd,public之一 |
extends、implements 是否重载全部方法 | 是 | 子类只重载定义为抽象的方法 |
重载的方法参数是否一致 | 完全一致 | 子类方法可以比父类多,但不能少, 多的参数必须给默认值否则报错 |
是否支持多项extends,implements | 可以 | 类只能单一继承 |
是否能实例化 | 不能 | 不能,只能被继承 |
其他 | 有一个抽象方法的类必须被定义为抽象 |