Java Reference
In-Depth Information
5. Are the identifiers firstName and FirstName the same?
6. Evaluate the following expressions:
a. 25 / 3
b. 20 - 12 / 4 * 2;
c. 32 % 7
d. 3 - 5 % 7
e. 18.0 / 4
f. 28 - 5 / 2.0
g. 17 + 5 % 2 - 3
h. 15.0 + 3.0 * 2.0 / 5.0
7. If x = 5 , y = 6 , z = 4 , and w = 3.5 , evaluate each of the following
expressions, if possible. If it is not possible, state the reason.
a. (x + z) % y
b. (x + y) % w
c. (y + w) % x
d. (x + y ) * w
e. (x % y) % z
f. (y % z) % x
g. (x * z) % y
h. ((x * y) * w) * z
8. Given:
int num1, num2, newNum;
double x, y;
Which of the following assignments are valid? If an assignment is not valid,
state the reason. When not given, assume that each variable is declared.
num1 = 35;
a.
newNum = num1 - num2;
b.
num1 = 5; num2 = 2 + num1; num1 = num2 / 3;
c.
num1 * num2 = newNum;
d.
x = 12 * num1 - 15.3;
e.
num1 * 2 = newNum + num2;
f.
x / y = x * y;
g.
num2 = num1 % 2.0;
h.
newNum = ( int ) (x) % 5;
i.
Search WWH ::




Custom Search