Learning Essentials
Replication of functions (override)
Call the member function of the parent class using Super
This (): Call a constructor in this class
This. : Call a member function in this class
Super (): Call the constructor in the parent class
Super (): Call a member function in the parent class
Class person{string name, int age, void introduce () {System.out.println ("My Name is" +name+ ", I Am" + ");}
Replication (override)//1. In the two classes that have a parent-child relationship,//2. The parent class and subclass each have a function, the definitions of the two functions (return value type, function name, and argument list) are exactly the same class Student extends person{string Address;void introduce () {//system.out.println ("My name is" + name+ ", my Age is" +age "); Super.introduce ();//Call the parent class member function Objective to reduce duplication of code System.out.println ("My home in" + Address);}}
Class Test{public static void Main (String args[]) {Student s = new Student (); s.name = "Lin Feng"; s.age = 20;s.address = "Beijing"; s.in Troduce ();}}
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/1C/wKiom1R4LBCw4q4XAAAwq0lnIl8427.jpg "title=" 1.jpg " alt= "Wkiom1r4lbcw4q4xaaawq0lnil8427.jpg"/>
20 Replication of functions