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();
    }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes