student类
public class Student {
String name;
int age=0;
public Student(String name, int age) {
super();
this.name = name;
this.age = age;
}
public String show() {
return "学生姓名为" + name + ", 年龄为" + age;
}
}
Undergaduate类
public class Undergaduate extends Student{
String degee;
public Undergaduate(String name, int age,String degee) {
super(name, age);
this.degee=degee;
}
public String show() {
return "学生姓名为" + name + ", 年龄为" + age +", 学位为" + degee;
}
}
温馨提示:答案为网友推荐,仅供参考