Logo Passei Direto
Buscar
Material
páginas com resultados encontrados.
páginas com resultados encontrados.

Prévia do material em texto

Certified Java Programmer Mock Exam 14
class Blue { 
 public static void main (String[] args) { 
 byte b1 = (byte)(2 * Byte.MAX_VALUE); 
 byte b2 = -1; 
 byte b3 = -2; 
 byte b4 = -3; 
 System.out.println((b1==b2)+","+(b1==b3)+","+(b1==b4)); 
 } 
} 
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: false,true,false 
d. Prints: true,false,false 
e. Compiler error. 
f. Runtime error. 
g. None of the Above 
 
Capítulo 3 – Operators and Assignments (B)
 
Question 1 
 
class A { 
 static boolean m1(String s, boolean b) { 
 System.out.print(s + (b ? "T" : "F")); 
 return b; 
 } 
 public static void main(String[] args) { 
 m1("A",m1("B",false) || m1("C",true) || m1("D",false)); 
 } 
} 
What is the result of attempting to compile and run the above program? 
a. Prints: ATBFCT 
b. Prints: ATBFCTDF 
c. Prints: BFCTAT 
d. Prints: BTCTDFAT 
e. Runtime error 
f. Compiler error 
g. None of the above 
 
Question 2 
class A { 
 public static void main(String[] args) { 
 final short s1 = 1; // 1 
 final char c1 = 1; // 2 
 byte b1 = s1; // 3 
 byte b2 = c1; // 4 
 byte b3 = 1; // 5 
 byte b4 = 1L; // 6 
 byte b5 = 1.0; // 7 
 byte b6 = 1.0d; // 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 3 
class V { 
 public static void main (String[] args) { 
 float a = Float.POSITIVE_INFINITY; 
 double b = Double.POSITIVE_INFINITY; 
 double c = Double.NaN; 
 System.out.print((a == b)+","+(c == c)+","+(c != c)); 
 } 
} 
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: false,true,false

Mais conteúdos dessa disciplina