0
이 표시됩니다. 이 예제 결과는 다음과 같습니다. feline cougar c c부모 클래스의 변수에 액세스하면 하위 클래스 변수
그러나 super.type 메서드를 호출합니다.
class Feline {
public String type = "f ";
public Feline() {
System.out.print("feline ");
}
}
public class Cougar extends Feline {
public Cougar() {
System.out.print("cougar ");
}
void go() {
type = "c ";
System.out.print(this.type + super.type);
}
public static void main(String[] args) {
new Cougar().go();
}
}
나는 feline cougar c f.