One: Inherit extends
Features: Subclasses inherit all the properties and methods of the parent class (but not the construction method), and can add new properties and methods for themselves. Java only supports single inheritance [a subclass has only one parent class].
Pros: Improve the reusability of your code.
Two: Super keyword
1. The constructor of the calling parent class can be displayed by using the Super keyword in the first line of the constructor method
2. The normal method of calling the parent class is displayed
3 access Modifiers
Used to modify a class, method, member variable:
Public: Publicly, everything is visible
Private: This class is visible
Protected: protected; visible to this class, all subclasses, and this package
Default (no modifier): This package is visible [if the child parent class is not in the same package, the subclass cannot access the members of the default access modifier in the parent class]
4. Method rewriting (overload)
1. Two methods that occur in subclasses and parent classes
With the same method name, argument list, and return value type, the access scope cannot be reduced.
Used when not satisfied with a method in the parent class [for polymorphism]
2. Method overrides and Method overloads
Overloading: Multiple methods in the same class occur, with the same method name, the parameter list must be different
Override: Occurs between child parent classes, same method name, same argument list, same return value type
Java Fundamentals 2