class Student { String name; int age; public Student(){} public Student(String getname,int getage) { name = getname; age = getage; } void show() { System.out.println("我的名字叫"+name+",今年"+age+"岁!"); } } class Undergraduate extends Student { private String degree; public Undergraduate(String getname,int getage,String getdegree) { name = getname; age = getage; degree = getdegree; } void show() { System.out.println("我的名字叫"+name+",今年"+age+"岁!来自"+degree+"专业。"); } } public class test01 { public static void main(String [] args) { Student stu = new Student("小明",5); Undergraduate und = new Undergraduate("小红",6,"通信工程"); stu.show(); und.show(); } }