this 关键字的指向 — 程序设计选择题
题目
阅读如下代码:
class Student {
private String name;
private int age;
Student() { this("未命名", 18); }
Student(String name, int age) { this.name = name; this.age = age; }
}
关于代码中两处 this 的用法,下列说法正确的是:
A. 第一处 this(...) 可放在 Student() 方法的任意一行
B. 第二处 this.name 中的 this 指代当前正在构造的对象,用于区分同名成员变量与参数
C. this("未命名", 18) 调用的是 Student(String name, int age) 之外的构造方法
D. 两处 this 均可省略而不影响程序含义与结果