Multiple choice technology programming languages

What is the result when you compile and run the following code? public class Test { public void method() { for(int i = 0; i < 3; i++) { System.out.print(i); } System.out.print(i); } }

  1. 0122

  2. 0123

  3. Compilation error

  4. None of these

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

The variable i is declared within the initialization of the for loop, meaning its scope is restricted to the loop body. Referencing i outside the loop in the subsequent print statement causes a compilation error, making other choices incorrect.