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);     } }
点赞 评论

相关推荐

某牛奶:一觉醒来全球程序员能力下降200%,小伙成功scanf惊呆在座个人。
点赞 评论 收藏
分享
头像
11-09 17:30
门头沟学院 Java
TYUT太摆金星:我也是,好几个华为的社招找我了
点赞 评论 收藏
分享
牛客网
牛客企业服务