What will be the output of following code?

class A
{
    {
        System.out.print("5");
    }
    
    static {
        System.out.print("3");
    }
    
    public A() {
        System.out.print("4");
    }
}
        
public class B extends A {
    {
        System.out.print("2");
    }
    
    static {
        System.out.print("6");
    }
    
    public B() {
        System.out.print("1");
    }
    
    public static void main(String[] args) {
        new B();
    }
}
Explanation
Get an explanation when it's available:

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback