class Student { String name; int age; public Student(String co_name,int co_age){ name = co_name; age = co_age;   }   public void show(){ System.out.println("我的名字是"+name+":"+age+"years old!");   } } class Undergradute extends Student{ String degree; public Undergradute(String co_name,int co_age,String getDegree){ super(co_name,co_age);   degree = getDegree; } public void show(){ System.out.println("我是"+name+",今年"+age+"岁,学位是"+degree); } } class Test{ public static void main(String[] args){ Student stu1 = new Student("明仔",23);   Student stu2 = new Student("红红",22);   Student stu3 = new Undergradute("继伟",30,"本科");   Student stu4 = new Undergradute("小霞",28,"研究生");   stu1.show();   stu2.show(); stu3.show(); stu4.show(); } }
点赞 评论

相关推荐

04-03 09:32
已编辑
华南农业大学 golang
我的代码出BUG了:"晚点发个邮件调整一下时间",你收到新的邮件没,如果没有收到新的邮件,那就需要进入面试链接留痕,否则系统会判定你迟到
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务