🎴 Flashcard Mode

Java Web Programming: Servlets, MVC, and Struts

Card1 / 20
Mastered0
Review0
QuestionClick to flip

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?

AnswerClick to flip back
A
i = 5 and j = 6
💡 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.

Change Mode