Prévia do material em texto
Certified Java Programmer Mock Exam 49
Error error = new Error();
Exception exception = new Exception();
System.out.print((exception instanceof Throwable) + ",");
System.out.print(error instanceof Throwable);
}
}
What is the result of attempting to compile and run the program?
a. Prints: false,false
b. Prints: false,true
c. Prints: true,false
d. Prints: true,true
e. Compiler Error
f. Run Time Error
g. None of the Above
Question 13
class Orange {
public static void main(String args[]) {
byte b = -1;
switch(b) {
case 0:
System.out.print("zero ");
break;
case 100:
System.out.print("100 ");
break;
case 1000:
System.out.print("1000 ");
break;
default: System.out.print("Default ");
}
}
}
What is the result of attempting to compile and run the above program?
a. Prints: zero
b. Prints: 100
c. Prints: 1000
d. Prints: Default
e. Runtime error
f. Compiler error
g. None of the above
Question 14
class Violet {
public static void main(String args[]) {
int x = -5;
int success = 0;
do {
switch(x) {
case 0: System.out.print("0");
x += 5; break;
case 1: System.out.print("1");
x += 3; break;
case 2: System.out.print("2");
x += 1; break;
case 3: System.out.print("3");
success++; break;
case 4: System.out.print("4");
x -= 1; break;
case 5: System.out.print("5");
x -= 4; break;
case 6: System.out.print("6");
x -= 5; break;
default:
x += x