What will be printed out as a result of the following code execution / compilation?
  class A {
  public A() { System.out.print("A"); }
}
 class B {
  public B() { System.out.print("B"); }
}
 class C {
  public C() { System.out.print("C"); }
}
public class D extends C {    
  private A objA = new A();
  private static B objB = new B();    
  
  public D() { System.out.print("D"); }
  
  public static void main(String[] args){
    new D();
  }
}
Explanation
According to JLS the object initialization procedure is:
1. Static fields are initialized during the class loading
2. Superclass initialization
3. Initialization of the fields in the order of priority before any class constructor is called
4. The class constructor

Mobile Beta

Get it on Google Play
or Subscribe for future quizzes