首页 > 试题广场 >

知识点:Java 910(单选) What is the

[不定项选择题]
知识点:Java 9/10(单选)
What is the output of the following program?

class A {
    static { System.out.print("A"); }
}
class B {
    static { System.out.print("B"); }
}
class C {
    static { System.out.print("C"); }
}
class D {
    static { System.out.print("D"); }
}

public class InitOrder {
    B b = new B();
    static A a = new A();
    public static void main(String[] args) {
        try {
            int a = 1;
            if (a > 0) {
                new D();
                throw new RuntimeException("");
            } else {
                new C();
            }
        } finally {
            new B();
        }
    }
}

  • ABD
  • BAD
  • ADCB
  • ADB
  • ABDC

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