Difference Between Abstract Class and Interface in Java_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Difference Between Abstract Class and Interface in Java

Difference Between Abstract Class and Interface in Java

 2017/12/21 15:56:20  wantongliu  程序员俱乐部  我要评论(0)
  • 摘要:No.1:AbstractclasscanextendonlyoneclassoroneabstractclassatatimeinterfacecanextendanynumberofinterfacesatatimeNo.2:Abstractclasscanbeextended(inherited)byaclassoranabstractclassInterfacescanbeextendedonlybyinterfaces
  • 标签:Java class
No.1:
Abstract class can extend only one class or one abstract class at a time
interface can extend any number of interfaces at a time

No.2:
Abstract class can be extended(inherited) by a class or an abstract class
Interfaces can be extended only by interfaces. Classes has to implement them instead of extend

No.3:
Abstract class can have both abstract and concrete methods
Interface can only have abstract methods, they cannot have concrete methods

No.4:
In abstract class, the keyword ‘abstract’ is mandatory to declare a method as an abstract
In interfaces, the keyword ‘abstract’ is optional to declare a method as an abstract because all the methods are abstract by default

No.5:
Abstract class can have protected and public abstract methods
Interface can have only public abstract methods

No.6:
Abstract class can have static, final or static final variables with any access specifier
Interface can have only public static final (constant) variable

发表评论
用户名: 匿名