Prévia do material em texto
Certified Java Programmer Mock Exam 25
What is the result of attempting to compile and run the above program?
a. Prints: 0,0,0
b. Prints: 0,0,3
c. Prints: 0,3,0
d. Prints: 0,3,3
e. Prints: 3,0,0
f. Prints: 3,0,3
g. Prints: 3,3,0
h. Prints: 3,3,3
i. Runtime error
j. Compiler error
k. None of the above
Question 7
class V {
public static void main (String[] args) {
System.out.print(Float.NaN % 2 + ",");
System.out.print(2 % Float.NaN);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: NaN,NaN
b. Prints: NaN,2.0
c. Prints: 2.0,NaN
d. Prints: 2.0,2.0
e. Runtime error
f. Compiler error
g. None of the above
Question 8
class L {
public static void main (String s[]) {
int i = 1 | 2 ^ 15 & 7 ^ 13 | 2;
System.out.println(i % 5);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 1
b. Prints: 2
c. Prints: 3
d. Prints: 4
e. Prints: 5
f. Runtime error
g. Compiler error
h. None of the above
Question 9
class Chartreuse {
public static void main (String[] args) {
short i = (short)Float.NEGATIVE_INFINITY;
short j = (short)Float.POSITIVE_INFINITY;
short k = (short)Float.NaN;
System.out.println((i == Short.MIN_VALUE) +
", " + (j == Short.MAX_VALUE) +
", " + (k == 0));
}
}
What is the result of attempting to compile and run the above program?
a. Prints: false, false, false
b. Prints: false, false, true
c. Prints: true, true, false
d. Prints: true, true, true
e. Compiler error.
f. Run time error.
Question 10
class B {
static boolean m(boolean b) {
System.out.print(b + " ");
return b;
}
public static void main(String[] args) {
boolean a = false;
boolean b = false;
boolean c = true;
boolean d = false;
m(m(a | b == c & d) == m((a | b) == (c & d)));
}
}