Q. What will be the output for the below code?
public class Test{
static{
int a = 5;
}
public static void main(String[] args){
System.out.println(a);
}
}
β
Correct Answer: (A)
Compile with error
Explanation: A variable declared in a static initializer is not accessible outside its enclosing block.