Prévia do material em texto
Certified Java Programmer Mock Exam 19
What is the result of attempting to compile and run the above program?
a. Compiler error at line 3.
b. Compiler error at line 4.
c. Compiler error at line 5.
d. Compiler error at line 6.
e. Compiler error at line 7.
f. Run time error.
g. None of the above.
Capítulo 3 – Operators and Assignments (C)
Question 1
class A {
public static void main(String[] args) {
char a = 'a'; // 'a' = 97
char b = 'b'; // 'b' = 98
System.out.print(a + b + "" + a + b);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 290
b. Prints: 195195
c. Prints: 195ab
d. Prints: ab195
e. Prints: abab
f. Runtime error
g. Compiler error
h. None of the above
Question 2
class V {
public static void main (String[] args) {
System.out.print((0.0 * -0.0)+","+(-0.0 * -0.0)+",");
System.out.print((0.0 + -0.0));
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 0.0,0.0,0.0
b. Prints: 0.0,0.0,-0.0
c. Prints: 0.0,-0.0,0.0
d. Prints: 0.0,-0.0,-0.0
e. Prints: -0.0,0.0,0.0
f. Prints: -0.0,0.0,-0.0
g. Prints: -0.0,-0.0,0.0
h. Prints: -0.0,-0.0,-0.0
i. Runtime error
j. Compiler error
k. None of the above
Question 3
class A {
public static void main(String[] args) {
short s1 = 1; //1
char c1 = 1; //2
byte b1 = s1; //3
byte b2 = c1; //4
final short s2 = 1; //5
final char c2 = 1; //6
byte b3 = s2; //7
byte b4 = c2; //8
}
}
What is the result of attempting to compile the program?
a. Compiler error at 1
b. Compiler error at 2
c. Compiler error at 3
d. Compiler error at 4
e. Compiler error at 5
f. Compiler error at 6
g. Compiler error at 7
h. Compiler error at 8
i. Runtime error.
j. None of the Above
Question 4
class N {
public static void main (String[] s) {