Abstract class: A. classes that contain one or more abstract methods or semantics must be defined as abstract classes.
B. inherit all the abstract methods or
Attention. Otherwise, the derived class must also be an abstract class until it is fully realized.
C. abstraction must be public ).
D. There is no object entity in the abstract class, but the variable can be affirmed. In addition, the abstract class
There can be non-Abstract methods for derivative class.
Interface: 1. define abstract methods in the interface, indexing, and events
2. The interface must be implemented by a type. Therefore, it can only be declared as public by default.
Static
3. All methods, indexes, and events in the interface must be fully implemented.
4. One class can only bear one base class, but multiple interfaces can be implemented. The base class of the class must be placed at the most
First, and then the interface, which is separated by teasing.
1. interfaces can only contain methods and fields. abstract classes can contain methods or attributes and fields;
2. Methods in interfaces do not need to be implemented, but abstract classes can have implemented methods;
3. interfaces can replace multiple inheritance to some extent.
4. Implementing interfaces means that all methods in interfaces must be implemented. If you inherit the subclass or abstract class of an abstract class, you can only implement some methods.
5. interfaces and abstract classes are not converted into objects by instances.
I think the reason why many people are not clear about the image and interface may be that the interface is good or abstract.
I have talked a lot about it in the book, and many people have said it countless times. I think the main reason for using interfaces is that the project grows and more people are involved. There are three developers, three developers, and four developers, but to improve development efficiency, we need to do some basic work, such as some common Code methods and functions. So we put these methods and functions in the abstract class. As long as the subclass inherits the class, it will have the method. This basic class is the image class. However, programming also encounters another situation: the manager is Zhang San, the development system client, and Wang Wu, the development server. But how does the client access the server? This requires an Intermediate contract, which can be understood by both parties, communications are available as long as both parties comply. This is the interface.