Multiple choice technology programming languages

package loop; public class TestLoop6 { void testFor() { for (int i = 1; i < 10; i++) { System.out.println("i in for loop = " + i); if (i == 1) { return; } } System.out.println("For loop over"); } public static void main(String[] args) { TestLoop6 tl = new TestLoop6(); tl.testFor(); System.out.println("Method call over"); } }

  1. i in for loop = 1 For loop over Method call over

  2. i in for loop = 1 Method call over

  3. Compiler Error

  4. Exception

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

The for loop starts with i=1 and prints it. The if condition (i==1) is true, so return immediately exits the testFor() method. Therefore, the code after the for loop (For loop over) never prints, and execution continues in main with Method call over.