class Student {
protected String name;
protected int age;
public Student(String name,int age){
this.name=name;
this.age=age;
}
public void show(){
System.out.println("学生的名字为:"+this.name+",学生的年龄为:"+this.age);
}
}
class Undergrdute extends Student {
private String degree;
public Undergrdute(String name,int age,String degree){
super(name,age);
this.degree=degree;
}
public void show(){
System.out.println("学生的名字为:"+super.name+
",学生的年龄为:"+super.age+
",学生的专业为:"+this.degree);
}
}
public class Test{
public static void main(String[] args){
Student s1 = new Student("小明",20);
Student s2 = new Undergrdute("小辉",25,"计算机");
s1.show();
s2.show();
}
}