publicclassSuperTest{publicstaticvoidmain(String[] args){
Student s =newStudent();
s.show();
s.study();}}
publicclassPerson{
String name;
int age;
int id =1002;//身份证号publicPerson(){}publicPerson(String name){this.name = name;}publicPerson(String name, int age){this.name = name;this.age = age;}publicvoideat(){
System.out.println("人,吃饭");}publicvoidwalk(){
System.out.println("人,走路");}}
publicclassStudentextendsPerson{
String major;
int id =1001;//学号publicStudent(){}publicStudent(String major){this.major = major;}
@Override
publicvoideat(){
System.out.println("学生多吃有营养的食物");}publicvoidstudy(){
System.out.println("学习");this.eat();super.eat();walk();super.walk();}publicvoidshow(){//此时name和age来自父类
System.out.println("name= "+ name +", age= "+ age);
System.out.println("name= "+this.name +", age= "+super.age);
System.out.println("id= "+ id);//子类id,this可以省略掉
System.out.println("id= "+super.id);//父类id}}