以下程序运行结果是( )
class Preson {
public Preson() {
System.out.println("is Preson");
}
}
public class Teacher extends Preson {
private String name = "tom";
public Teacher() {
System.out.println("is Teacher");
super();
}
public static void main(String[] args) {
Teacher t = new Teacher();
System.out.print(this.name);
}
}Is Preson teacher tom
Is Preson teacher tom
Is Preson teacher tom
编译出错
“super();”:
必须放在构造函数第一行
“System.out.print(this.name);”:
静态类中使用this不正确。
必须放在构造函数第一行
“System.out.print(this.name);”:
静态类中使用this不正确。