Multiple choice technology programming languages

Given: 11. int i = 1,j = 10; 12. do { 13. if(i>j) { 14. break; 15. } 16. j--; 17. } while (++i <5); 18. System.out.println(“i =” +i+” and j = “+j); What is the result?

  1. i = 6 and j = 5

  2. i = 5 and j = 5

  3. i = 5 and j = 6

  4. i = 6 and j = 4

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

In the do-while loop, j decrements each iteration. When i increments to 5 (via ++i in the while condition check), ++i < 5 becomes 5 < 5 (false), terminating the loop. At this point, j has decremented four times from 10 to 6, yielding i = 5 and j = 6.