单选题

main程序输出: interface Alpha {  &n...

发布于 2022-03-02 16:49:00

main程序输出:
interface Alpha {
    void f()
}
class Beta implements Alpha {
    public void f() {
        System.out.println("Beta.f()")
    }
    public void g() {
        System.out.println("Beta.g()")
    }
}
public class Main {
    public static void main(String[] args) {
        Alpha a = new Beta()
        a.f()
        System.out.println(a.getClass().getName())
        try {
            Beta b = (Beta)a
            b.g()
        } catch (Exception e) {
            System.out.println("Error")
        }
    }
}


登录后免费查看答案
关注者
0
被浏览
16
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看