Examveda
Examveda

What is the output for the below code?
public class A{
      static{
            System.out.println("static");
      }

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

      public A(){
            System.out.println("A");
      }

      public static void main(String[] args){
            A a = new A();
      }
}

A. A block static

B. static block A

C. static A

D. A

E. None of these

Answer: Option B

Solution(By Examveda Team)

First execute static block, then statement block and then constructor.


This Question Belongs to Java Program >> Declaration And Access Control

Join The Discussion

Related Questions on Declaration and Access Control