class Student { String name; int age; public void Student(String name,int age) { this.name = name; this.age = age; } public void show () { System.out.println("学生姓名:"+this.name+" 学生年龄:"+this.age); } } class Undergraduate extends Student { String degree; public void Undergraduate(String name,int age,String degree) { super.Student(name,age); this.degree = degree; } public void show () { System.out.println("学生姓名:"+this.name+" 学生年龄:"+this.age+" 学生学位:"+this.degree); } } public class StudentDemo { public static void main(String[] args) { Student s = new Student(); s.Student("小红",24); s.show(); Undergraduate u = new Undergraduate(); u.Undergraduate("小红",24,"硕士"); u.show(); } }