Multiple choice technology programming languages

class C{ int i; public static void main (String[] args) { int i; //1 private int a = 1; //2 protected int b = 1; //3 public int c = 1; //4 System.out.println(a+b+c); //5 }}

  1. compiletime error at lines 1,2,3,4,5

  2. compiletime error at lines 2,3,4,5

  3. compiletime error at lines 2,3,4

  4. prints 3

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Java does not allow access modifiers (private, protected, public) on local variables inside methods. These modifiers only apply to class members (fields and methods). Lines 2-4 are illegal because a, b, c are local variables in main() with access modifiers. Line 5 fails because those variables don't exist as declared.