abstract vs interface
时间:2014-02-09 16:25:01
收藏:0
阅读:327
- 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.
原文:http://www.cnblogs.com/leetcode/p/3541199.html
评论(0)