Q50
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);
A.
Compile with error
AnswerB.
5
C.
0
D.
Runtime Exception
E.
None of these
Answer: Option A
Solution
Answer: Option A
Solution:
A variable declared in a static initializer is not accessible outside its enclosing block.