consider the following code segment.\nint value = 15;\nwhile (value < 28) {\n system.out.println(value);\n…

consider the following code segment.\nint value = 15;\nwhile (value < 28) {\n system.out.println(value);\n value++;\n}\nwhat are the first and last numbers output by the code segment?\na 15 (first), 27 (last)\nb 15 (first), 28 (last)\nc 16 (first), 27 (last)\nd 16 (first), 28 (last)\ne 16 (first), 29 (last)
Answer
Explanation:
Step1: Initial value
The variable value is initialized to 15. The first number printed will be this initial value as the println statement is executed right away in the loop.
Step2: Loop condition check
The loop condition is value < 28. When value reaches 27, the loop condition is still true and 27 will be printed. When value becomes 28, the loop condition value < 28 is false and the loop terminates. So the last number printed is 27.
Answer:
A. 15 (First), 27 (Last)