java编程 有没有大神会的 帮帮忙谢谢了
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="+name+"\nage="+age);
}
}
class UnderGraduate extends Student{
protected String degree;
public UnderGraduate(String name, int age,String degree) {
super(name, age);
this.degree = degree;
}
public void show() {
System.out.println("name="+name+"\nage="+age+"\ndegree="+degree);
}
}
public class Test {
public static void main(String[] args) {
new Student("a",20).show();
new UnderGraduate("b",21,"undergraduate").show();
}
}
不知道为什么,"百度知道"现在不能插入代码了,就只能这么看了,复制起来可能有些麻烦。
好的谢谢你了
采纳了