Inheritance features: Inherits the properties and methods of the parent class. Single Inheritance (Multilayer inheritance) inheritance in C + + is multiple inheritance
Properties: Replication of methods (Overrides)
Inheritance in Java is the same as in OC.
For example: people can keep dogs;
People----> Dogs: Overall and partial (own) relationships.
Team----> Players: Overall and part of the relationship. The code is the most common
Has a relationship
People----> Students: Students are people: the existence of an inheritance relationship, whether the bottom of the show, there are specific circumstances to decide.
How to tell if there is an inheritance relationship between two things: is a who is who is set up. The establishment has the inheritance relationship.
A:B: The notation of inheritance in OC
How inheritance relationships are represented in Java:
Use keyword: extends to represent inheritance.
Inheritance: With keyword: extends
Structure:
Class A extends Class B: Class A inherits Class B.
Considerations in Inheritance:
1. Do not inherit for inheritance, do not want to save code, any class is inherited
2. The private member variable of the parent class cannot be inherited.
3. The method of constructing a parent class cannot be inherited.
4. When a subclass calls its own constructor method, the non-parametric constructor method in the parent class is called by default.
Inheritance of the 3 major features in Java