public class Test {     public static void main(String[] args) {         Student student = new Student("肖捷", 28);         student.show();         Undergraduate undergraduate = new Undergraduate("***", 29, "经济学");         undergraduate.show();     } } class Student {     private String name;     private int age;     Student (String name, int age){         this.name = name;         this.age = age;     }     protected void show() {         System.out.println("学生名字是:" + name);         System.out.println("该学生的年龄是:" + age);     } } class Undergraduate extends Student{     private String degree;     Undergraduate(String name, int age, String degree) {         super(name, age);         this.degree = degree;     }          protected void show() {         super.show();         System.out.println("该学生的学位是:" + degree);     } }
点赞 评论

相关推荐

宝宝巴逝:给他一巴掌看他还发不发癫
点赞 评论 收藏
分享
牛客网
牛客企业服务