Often see such a problem, is to ask the difference between the two, I also summed up:
1, Macro said, one is a class, one is an interface, the class supports only single inheritance, the interface supports multiple inheritance
2, on the microscopic level, is from the inside.
A, member variable aspect
-
- Interfaces can contain methods, properties, constants (unchanged, but do not want to always take from the database the amount of wasted resources)
- An abstract class can include any member of an interface, and it needs to satisfy the methods that can be implemented internally and those that are not implemented, and must have methods that are not implemented.
B, the interface class is public, and the abstract class may not be public
c, generally used, the interface is at the top, and then the abstract class implements the interface, and then the object class implements the abstract class
D, implementing an interface is a must to implement all the virtual methods, but the abstract class is not
Same point
are not directly instantiated
Differences between interfaces and abstract classes in Java