public class Test_3 { public static void main(String[]args) { Student st=new Student("张三",18); Undergradute un=new Undergradute("李四",20,"硕士"); st.show(); un.show(); } } 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("姓名:"+name+','+"年龄:"+age); } } class Undergradute extends Student{ protected String degree; public Undergradute(String name, int age, String degree) { super(name,age); this.degree=degree; } public void show() { System.out.println("姓名:"+name+','+"年龄:"+age+','+"学位:"+degree); } }