Inheritance of the three main features in java and the inheritance of java features
Inheritance features: inherits the attributes and methods of the parent class. Single inheritance (Multi-Level inheritance) Multi-inheritance in c ++
Feature: Method Rewriting)
The Inheritance in java is the same as in OC.
For example, a human can raise a dog;
People ----> dogs: overall and partial (ownership) relationships.
Team ----> players: the relationship between the whole and the part. Code is the most common
Relationship between has
Student ----> Student: The student is a person. It indicates whether there is an inheritance relationship, and whether the relationship is displayed or not.
How to determine whether there is an inheritance relationship between two things: is a, who is, who is, and whether it is true. If it is set up, there is an inheritance relationship.
A: B: The Inheritance Method in OC
How to express the inheritance relationship in java:
Use keywords: extends to represent inheritance.
Inheritance: Use keywords: extends
Structure:
Class A extends Class B: Class A inherits Class B.
Notes for inheritance:
1. Do not inherit for inheritance, do not save Code, any class inherits
2. The private member variables of the parent class cannot be inherited.
3. the constructor of the parent class cannot be inherited.
4. When a subclass calls its own constructor, it calls the non-argument constructor in the parent class by default.