Java Reference
In-Depth Information
j.
z
is nonnegative.
k.
x
is even.
l.
x
is closer in value to
y
than
z
is.
2.
Given the variable declarations
int x = 4;
int y = -3;
int z = 4;
what are the results of the following relational expressions?
a.
x == 4
b.
x == y
c.
x == z
d.
y == z
e.
x + y > 0
f.
x - z != 0
g.
y * y <= z
h.
y / y == 1
i.
x * (y + 2) > y - (y + z) * 2
3.
Consider the following method:
public static void ifElseMystery1(int x, int y) {
int z = 4;
if (z <= x) {
z = x + 1;
} else {
z = z + 9;
}
if (z <= y) {
y++;
}
System.out.println(z + " " + y);
}
What output is produced for each of the following calls?
a.
ifElseMystery1(3, 20);
b.
ifElseMystery1(4, 5);
c.
ifElseMystery1(5, 5);
d.
ifElseMystery1(6, 10);
4.
Consider the following method:
public static void ifElseMystery2(int a, int b) {
if (a * 2 < b) {
a = a * 3;
} else if (a > b) {
Search WWH ::
Custom Search