The polymorphism of the class:
The polymorphism of a subclass object: a reference to a parent class to a subclass (an instance of a subclass is assigned to a parent class)
person P1 = new Man ();//upward transformation (equivalent to automatic conversion of basic data types)
Virtual method invocation: Refers to the object entity of the subclass through a reference to the parent class, and when the method is called, the child class is actually executing the method of overriding the parent class
P1.eat ();
P1.walk ();
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/49/wKioL1Y0scGS7y73AAGJ7mEs8kU461.jpg "title=" Polymorphism. png "alt=" wkiol1y0scgs7y73aagj7mes8ku461.jpg "/>
Transformation mechanism of Child parent class object: (Analogy to basic data type conversion mechanism)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/4B/wKiom1Y0sZugaqySAAE2EcTfznU683.jpg "title=" Child parent class object conversion. png "alt=" wkiom1y0szugaqysaae2ectfznu683.jpg "/>
Basic Java Learning 18