abstract vs interface

  • 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.

posted on 2014-02-09 05:11  brave_bo  阅读(185)  评论(0)    收藏  举报

导航