Given the following code, which statement is true?.
public class Main { public static void main(String[] args) { int k=0;//from ww w .j a v a2 s . co m int l=0; for (int i=0; i <= 3; i++) { k++; if (i == 2) break; l++; } System.out.println(k + ", " + l); } }
Select the one correct answer.
(c)
As it stands, the program will compile correctly and will print "3, 2" when run.
If the break statement is replaced with a continue statement, the loop will perform all four iterations and will print "4, 3".
If the break statement is replaced with a return statement, the whole method will end when i equals 2, before anything is printed.
If the break statement is simply removed, leaving the empty statement ( ;), the loop will complete all four iterations and will print "4, 4".