Java Notes

Numeric Expression Exercises

Name ______________________

Assume the following:

int i;
int j = 6;
int k = 10;

Give the values of the following expressions, or "X" for illegal.

1__________1 + 2 * 3
2__________1 + 2 - 3 * 4 / 5
3__________3 / 2
4__________3 / 2.0
5__________3.0 / 2

6__________1+2 * 3+4
7__________5 % 3
8__________6 % 3
9__________11 % 11
10__________8 % 2

11__________1 % 999
12__________20%3*2/2
13__________(((k)))
14__________k++
15__________++k

16__________7++
17__________k++ + ++j
18__________k+++++j
19__________k += 1
20__________k *= 2