Prévia do material em texto
Certified Java Programmer Mock Exam 21
", " + (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 9
1. class Green {
2. public static void main (String args[]) {
3. int[] i = null;
4. Cloneable c = i;
5. i = (int [])c;
6. }
7. }
What is the result of attempting to compile and run the above program?
a. Compiler error at line 3.
b. Runtime error at line 3.
c. Compiler error at line 4.
d. Runtime error at line 4.
e. Compiler error at line 5.
f. Runtime error at line 5.
g. Compiles and runs without error.
Question 10
class Fuchsia {
public static void main (String[] args) {
System.out.println((short)Integer.MIN_VALUE +
", " + (short)Integer.MAX_VALUE +
", " + (int)(char)Integer.MIN_VALUE +
", " + (int)(char)Integer.MAX_VALUE);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: -32768, 32767, -32768, 32767
b. Prints: -32768, 32767, 0, 65535
c. Prints: 0, 0, 0, 0
d. Prints: 0, -1, 0, 65535
e. Compiler error.
f. Run time error.
Question 11
class A {
static int m(int i) {
System.out.print(i + ",");
return 0;
}
public static void main (String[] args) {
int i = 0;
i = i++ + m(i);
System.out.print(i);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 0,0
b. Prints: 1,0
c. Prints: 0,1
d. Prints: 1,1
e. Runtime error
f. Compiler error
g. None of the above
Question 12
class M {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
int i = 1;
int j = m(i++) + m(i++) * m(i++) + m(i++);
System.out.print(j % 5);
}
}
What is the result of attempting to compile and run the above program?