一道Java编程题

2024-11-08 21:37:28
推荐回答(2个)
回答(1):

public class Person {

private static String name;

private static String sex;

private static int age;

Person(String name, int age) {
this.name = name;
this.age = age;
}

public void print() {
System.out.print("名字:" + name + " 性别:" + sex + " 年龄:" + age + " ");
}
}

public class Student extends Person {

private static String school;

private static String department;

private static String studentno;

Student(String name, int age, String school, String department,
String studentno) {
super(name, age);
this.school = school;
this.department = department;
this.studentno = studentno;
}

public void print() {
super.print();
System.out.println("学校是:" + school + " 系是:" + department + " 学号是:"
+ studentno);
}

}

回答(2):

index[0]=1;
index[1]=3;
index[2]=0;
index[3]=2;
int ref;}
这个}应该是多余的,你调试一下,在这里打个断点,运行会报错的。