What is the value of balance after the following code is executed?

```
int balance = 10;

while (balance >= 1) {
if (balance < 9)
break;
balance = balance - 9;
}
```
A. -1
B. 0
C. 1
D. 2


C. 1
Before the loop, balance is 10. The loop-continuation-condition is true (10 >= 1). In the first iteration, balance is reduced to 1. Since 1 >= 1 is true, the loop body is executed. Since balance < 9 is true, the break statement is executed to exit the loop. So, balance is 1 after the loop is finished. The correct answer for this question is C.

Computer Science & Information Technology

You might also like to view...

When applying the binary math _______________ calculation, a cleartext value of 0 combined with a key value of 0 equals 0, as does a cleartext value of 1 combined with a key value of 1. Further, a cleartext value of 0 combined with a key value of 1 equals 1, as does a cleartext value of 1 combined with a key value of 0.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The ____ PAM module provides a JAAS login module that prompts for a keystore alias and populates the subject with the alias's principal and credentials.

A. NTLoginModule B. SolarisLoginModule C. UnixLoginModule D. KeyStoreLoginModule

Computer Science & Information Technology

What is Math.rint(3.6)?

a. 3.0 b. 3 c. 4.0 d. 5.0

Computer Science & Information Technology

Write a void function using two type int call-by-reference parameters that swaps the values in the arguments. Be sure to include testable pre and post conditions.

What will be an ideal response?

Computer Science & Information Technology