super理解为 父类的
super可以调用属性、方法、构造器
package exer;
public class SuperTest {
public static void main(String[] args) {
Student s=new Student();
s.show();
s.eat();
}
}
class Person{
String name;
Person(){
this.name="张三";
}
public void eat(){
System.out.println("人:吃饭");
}
}
class Student extends Person{
int score;
Student(){
super();
this.score=100;
}
public void eat(){
System.out.println("学生:吃饭!");
super.eat();
}
public void study(){
System.out.println("学生:学习");
}
public void show(){
System.out.println(super.name+"的成绩是"+this.score);
}
}