首页 > 试题广场 >

main程序输出: class Alpha { ...

[单选题]
main程序输出:
class Alpha {
    Alpha get() {
        return this;
    }
    void message() {
        System.out.println("This is Alpha");
    }
}
class Beta1 extends Alpha {
    void message() {
        System.out.println("This is Beta1");
    }
}
class Beta2 extends Alpha {
    Beta2 get() {
        return this;
    }
    void message() {
        System.out.println("This is Beta2");
    }
}

public class Main {
    public static void main(String[] args) {
        new Beta1().get().message();
        new Beta2().get().message();
    }
}

  • This is Alpha

    This is Beta2
  • This is Alpha

    This is Alpha
  • This is Beta1

    This is Beta2
  • This is Beta1

    This is Alpha

这道题你会答吗?花几分钟告诉大家答案吧!