1. Members of the parent class that cannot be inherited:
Private members, subclasses, and parent classes are not in the same package, using the members of the default access permission, the constructor method.
2. Access modifiers:
Access decoration into similar bun class other
Private√
Default (Friendly) √√
Protected√√√
Public√√√√
3. Sequence of initialization of multiple inheritance relationships
Parent Class Property-Parent class construction Method-Subclass attribute-Subclass Construction method
4. Method overloading differs from method overrides:
Positional method Name parameter list return value access modifier
Method overloading homogeneous same different unrelated unrelated
Method overrides subclass the same as same or its subclasses are not strict with the parent class
5.super keyword to access the parent class members, be aware that:
1) Super can only appear in the methods and construction methods of subclasses
2) Super Call constructor method, can only be the first sentence
3) Super cannot access the private members of the parent class
6. When the parent class does not need to be instantiated, the parent class can be declared as an abstract class.
Public abstract class Name {}
7. When a subclass must override a parent class method, the parent class method can be declared as an abstract method.
Requirements for abstract methods:
1) There is no method body for abstract method;
2) Abstract methods must be in the abstract class;
3) An abstract method must be implemented in a subclass, unless the subclass is also an abstract class.
public abstract void Method name () {};
Java Fundamentals-Inheritance