Discuss / Java / 分享一下我昨天的面试题

分享一下我昨天的面试题

Topic source

HelloA  class

public class HelloA {

public HelloA() {
System.out.println("helloA");
}

{
System.out.println("AAA");
}

static {
System.out.println("AAA static");
}

}

HelloB  class

public class HelloB extends HelloA {

public HelloB() {
System.out.println("Hellob");
}

{
System.out.println("BBB");
}

static {
System.out.println("BBB static");
}

public static void main(String[] args) {
new HelloB();
}
}

问:运行结果是什么???

Joker.fu_95

#2 Created at ... [Delete] [Delete and Lock User]

先静后动,先父后子


  • 1

Reply