Differences between java Abstract classes and interfaces and java Abstract Interfaces
Zookeeper
Syntax:
1) abstract classes can provide implementation details of member methods, while interfaces can only have public abstract methods;
2) The member variables in the abstract class can be of various types, while the member variables in the interface can only be of the public static final type;
3) the interface cannot contain static code blocks and static methods, while the abstract class can have static code blocks and static methods;
4) A class can inherit only one abstract class, but a class can implement multiple interfaces.
Design Level:
Abstract is the relationship between inheritance and whether or not, and the interface implementation is the relationship between whether or not. It is better to say that there is an abstract class Door (Door) and a class inheritance subclass WoodDoor (wooden Door ), this is the inheritance of abstract classes. For example, there is a Bird class and an Airplane plane class. They all have a fly () method. There is no way to use abstract classes to solve this problem, the interface should be used, because it is clear that birds and planes are not sub-classes and parent classes. They only have a common behavior method. They both have the fly method. This is the concept of "whether.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.