Inheritance:

Inheritance of interfaces

Class inheritance

Java is single inheritance

There can only be one direct parent of a class

But a parent class can have more than one child class

The class in which the abstract method resides must be an abstract class

In parent-child inheritance, if the member variables have the same name, the subclass object is created with two forms of access:

Member variables are accessed directly from subclass objects

Whoever is on the left side of the equals sign will be used first, and if there is no sign, look up

Member variables are accessed indirectly through member methods

Whoever the method belongs to, use it first, and if it doesn’t, look up

Override:

In an inheritance relationship, the name of the method is the same, as is the argument list

Three uses of the Super keyword:

In a member method of a subclass, access a member variable of the parent class

In the member methods of a subclass, access the member methods of the parent class

In the constructor of a subclass, access the constructor of the parent class

Polymorphism:

Object name = new subclass name ();

Member variables cannot be overridden

The benefits of polymorphism

The left side stays the same, making the code more flexible and convenient

Different subclasses of objects as the parent class, you can shield the differences between different subclasses of objects, write common code, make common programming, to adapt to the changing needs.

Once assigned, a reference to the parent type can behave differently depending on the characteristics of the child object to which it is currently assigned. That is, the father acts like the son, not the son acts like the father.

// From the Dark Horse programmer course