A

Admin • 833.24K Points
Coach

Q. 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) static A D. A
  • Correct Answer - Option(B)
  • Views: 45
  • Filed under category Java
  • Hashtags:

Explanation by: Admin

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.