113k views
1 vote
int i = 0; while (i != 11) { System.out.print(" " + i); int sum = i; i++; sum++; } Group of answer choices It contains the value 11 after the loop is finished executing. It contains the value 10 after the loop is finished executing. It disappears after the loop is done executing. It is the cause of an infinite loop.

1 Answer

2 votes

Answer:

The answer to this question can be given as:

In this code, the sum value is 11. Which means It contains the value 11 after the loop is finished executing.

Explanation:

In the given code the firstly an integer variable i declare that assign a value that is 0. Then there is a while loop is define that is starts from 0 and ends with 10. In this loop, we print the value of i and we also declare an integer variable that is the sum. This variable holds the value of the i variable and both variable i and sum in an increment by 1 and the value of i will be 10 and the sum variable will end on 11 numbers. So the answer to this question is It contains the value 11 after the loop is finished executing.

User CinCout
by
6.7k points