What will be output of following java program? (Static Interview Question)

class StaticBlock

{

                static int a;

                static     //Static Block

                {

                                a=7;

                                System.out.println("Hello");

                }

                public static void main(String arg[])

                {

                                System.out.println("Main() Hello");

                                new StaticBlock();

                                new StaticBlock();

                }

}

Static Block.PNG

, , , , , , , ,

Leave a Reply