填空题:Java程序阅读并填空-构造方法
设有以下Java程序段,请阅读程序并完成注释处的程序逻辑填空。
class Person {
String name, department;
int age;
public Person(String n){ name = n; }
public Person(String n, int a){ name = n; age = a; }
public Person(String n, String d, int a) {
// 完成Person(String n, int a)的逻辑
department = d;
}
}
答案:
第1空:this(n,a); ||
class Person {
String name, department;
int age;
public Person(String n){ name = n; }
public Person(String n, int a){ name = n; age = a; }
public Person(String n, String d, int a) {
// 完成Person(String n, int a)的逻辑
department = d;
}
}
答案:
第1空:this(n,a); ||