abstract classes and abstract methods

A class with abstract methods is an abstract class.
Non-abstract member methods in an abstract class can be inherited by its subclasses! For example:
there is an abstract class: Human
which has a non-abstract member method: eat (because it is assumed that the method of eating for humans is chewing)

The method modified with abatract is an abstract method, and the abstract method only has the method name, return value, and parameters Table, there is no specific implementation process, the implementation process should be written in the method overridden in the implementation class. And abstract methods are: get language, get gender and so on.
When a subclass needs to inherit the abstract class "human", it does not need to override the method of eating, but only needs to override the "get language" method to meet the corresponding special object requirements.
So all in all, non-abstract member methods in abstract classes are also mechanisms to improve reuse.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326908496&siteId=291194637