注意:此页面搜索的是所有试题
以下程序的输出结果__。
public class Father {
String name, address, tel;
int age;
public Father(String name, int age) {
this.name = name;
this.age = age;
}
void out() {
System.out.print("姓名:" + name);
System.out.print(" 年龄:" + age);
}
void outOther() {
System.out.print(" 家庭住址:" + address);
System.out.print(" 电话:" + tel);
}
}
class Son extends Father {
String school;
public Son(String name, int age) {
super(name, age);
}
void out() {
super.out();
super.outOther();
System.out.println(" 学校:" + school);
}
public static void main(String args[]) {
Son son = new Son("Tom", 15);
son.address = "金水区";
son.school = "九中";
son.tel = "66123456";
son.out();
}
}
public class Father {
String name, address, tel;
int age;
public Father(String name, int age) {
this.name = name;
this.age = age;
}
void out() {
System.out.print("姓名:" + name);
System.out.print(" 年龄:" + age);
}
void outOther() {
System.out.print(" 家庭住址:" + address);
System.out.print(" 电话:" + tel);
}
}
class Son extends Father {
String school;
public Son(String name, int age) {
super(name, age);
}
void out() {
super.out();
super.outOther();
System.out.println(" 学校:" + school);
}
public static void main(String args[]) {
Son son = new Son("Tom", 15);
son.address = "金水区";
son.school = "九中";
son.tel = "66123456";
son.out();
}
}
参考答案