Someone in the Forum asked about the embodiment of polymorphism,
Then there is a reply below:
The polymorphism in Java is embodied in two aspects. The first is the polymorphism generated by method overloading, the second is the Runtime polymorphism produced by method overwrite mentioned in the video (parent class references to subclass objects)
Thank you for your reply. Then, I have a reply below:
There are three forms of polymorphism in Java: 1. Method rewriting, 2. Method overloading, 3. Object polymorphism.
Seeing such a neat answer, I almost thought it was a standard answer.
In the spirit of seeking truth and being pragmatic, I opened it silently.
"Bixiangdong Java video tutorial day 02 object-oriented polymorphism (scalability)" video.
At the end of the video, instructor Bi briefly summarized some polymorphism knowledge points:
Embodiment of Polymorphism
The parent class references its own subclass object.
The reference of the parent class can also receive its own subclass object.
The premise of Polymorphism
It must be related to the class. Either inherit or implement.
There is usually another premise: Overwrite
Benefits of Polymorphism
The appearance of polymorphism greatly improves the scalability of the program.
Disadvantages of Polymorphism
It improves scalability, but can only use the parent class reference to access members in the parent class.
Well, at a glance.
From the embodiment of polymorphism ......