tg-me.com/topJavaQuizExplain/257
Last Update:
What is the result of the code snippet?
❌ A. 11
❌ B. 13
✅ C. 23
❌ D. 33
❌ E. 50
❌ F. The code will not compile because of line 7
Explanation:
Prior to the first iteration, sing = 8, squawk = 2, and notes = 0. After the iteration of the first loop, sing is updated to 7, squawk to 4, and notes to the sum of the new values for sing + squawk, 7 + 4 = 11. After the iteration of the second loop, sing is updated to 6, squawk to 6, and notes to the sum of itself, plus the new values for sing + squawk, 11 + 6 + 6 = 23. On the third iteration of the loop, sing > squawk evaluates to false, as 6 > 6 is false. The loop ends and the most recent value of sing, 23, is output, so the correct answer is option C.
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/topJavaQuizExplain/257