Page 779 - AP Computer Science A, 7th edition
P. 779

25. (D) Statement I is false, since if 100 ≤ num ≤ 109, the body of the while loop will be executed just once. (After this single pass through the loop, the value of num will be 10, and the test if (num > 10) will fail.) With just one pass, newNum will be a one-digit number, equal to temp (which was the original num % 10). Note that statement II is true: There cannot be an infinite loop since num /= 10 guarantees termination of the loop. Statement III is true because if num ≤ 10, the loop will be skipped, and newNum will keep its original value of 0.


































































































   777   778   779   780   781