Multiple choice technology web technology

What will be the output of the following JSP code snippet at run-time when it is accessed the third time? <% int test = 0; %> <% ++test; %> The value of test is <%= test %>

  1. The value of the 'test' variable will be 2.

  2. The value of the 'test' variable will be 0.

  3. The value of the 'test' variable will be 1.

  4. The variable 'test' must be declared at global scope, else a run-time error will occur

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

In JSP scriptlets, variables declared without explicit scope are local to the request. Each HTTP request reinitializes test to 0, then increments to 1. The third access still shows 1, not 3.