您的位置:首页 > Web前端

Difference between Abstract class and interface

2014-03-04 15:30 435 查看
Unlike interfaces,
abstract classes can contain fields that are
not static and final, and they can contain

implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial

 implementation, leaving it to subclasses to complete the implementation. If an abstract class contains
only abstract

 method declarations, it should be declared as an interface instead.

Multiple interfaces can be implemented by classes anywhere in the class hierarchy, whether or not they are

 related to one another in any way. Think of Comparable or Cloneable, for example.

By comparison, abstract classes are most commonly subclassed to share pieces of implementation. A single

 abstract class is subclassed by similar classes that have a lot in common (the implemented parts of the abstract

 class), but also have some differences (the abstract methods).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  interface abstract