首页 > 其他 > 详细

abstract vs interface

时间:2014-02-09 16:25:01      阅读:326      评论:0      收藏:0      [点我收藏+]
  • Abstract classes can have  constant, members, method  and method implementations, whereas interfaces can only have may only contain method signature and constant declarations(both static and final)static final.
  • Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public.
  • When inheriting an abstract class, the child class must define the abstract methods, whereas an interface can extend another interface and methods don‘t have to be defined.
  • A child class can only extend a single abstract (or any other) class, whereas an interface can extend or a class can implement multiple other interfaces.
  • A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility.

abstract vs interface

原文:http://www.cnblogs.com/leetcode/p/3541199.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!