class Person{
private String name;
private String addr; private char sex; private int age; public void setName(String name){ this.name = name; } public void setAddr(String addr){ this.addr = addr; } public void setSex(char sex){ this.sex = sex; } public void setAge(int age){ this.age = age; } public Person(String name,String addr,char sex,int age){ this.setName(name); this.setAddr(addr); this.setSex(sex); this.setAge(age); } public Person(String name,int age){ this.setName(name); this.setAge(age); } public Person(){} public String getInfo(){ return "name: "+this.name+ "; addr: "+this.addr+ "; sex: "+this.sex+ "; age: "+this.age; } public void say(){ System.out.println(this.getInfo()); } } class Student extends Person{ private int math; private int english; public void setMath(int math){ this.math = math; } public void setEnglish(int english){ this.english = english; } public Student(String name,String addr,char sex,int age,int math,int english){ super(name,addr,sex,age); this.math = math; this.english = english; } public Student(String name,int age){ super(name,age); } public Student(){}; public String getInfo(){ return super.getInfo()+ "; math: "+this.math+ "; english: "+this.english; } public void say(){ super.say(); } } public class Test{ public static void main(String[] args){ Person per1 = new Person("李四",27); Person stu1 = new Student("张三","天津",'M',20,68,91); Student stu2= new Student("赵二","北京",'M',20,98,82); per1.say(); stu1.say(); stu2.say(); } }