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 15
d. Prints: false,true,true 
e. Prints: true,false,false 
f. Prints: true,false,true 
g. Prints: true,true,false 
h. Prints: true,true,true 
i. Runtime error 
j. Compiler error 
k. None of the above 
 
Question 4 
class V { 
 public static void main (String[] args) { 
 System.out.print(Float.POSITIVE_INFINITY % 2 + ","); 
 System.out.print(Float.NEGATIVE_INFINITY % 2 + ","); 
 System.out.print(2 % Float.NEGATIVE_INFINITY); 
 } 
} 
What is the result of attempting to compile and run the above program? 
a. Prints: NaN,NaN,NaN 
b. Prints: NaN,NaN,2.0 
c. Prints: NaN,NaN,2 
d. Prints: 2.0,2.0,2.0 
e. Prints: 2,2,2 
f. Runtime error 
g. Compiler error 
h. None of the above 
 
Question 5 
1. interface I1 {} 
2. interface I2 {} 
3. class Base implements I1 {} 
4. class Sub extends Base implements I2 {} 
5. class Silver { 
6. public static void main(String []args) { 
7. Base[] base = {new Base()}; 
8. Sub sub[] = new Sub[1]; 
9. Object obj = base; 
10. sub = (Sub[])obj; 
11. I1 []i1 = (I1[])obj; 
12. } 
13. } 
What is the result of attempting to compile and run the above program? 
a. Compiler error at line 8. 
b. Runtime error at line 8. 
c. Compiler error at line 9. 
d. Runtime error at line 9. 
e. Compiler error at line 10. 
f. Runtime error at line 10. 
g. Compiler error at line 11. 
h. Runtime error at line 11. 
i. Compiles and runs without error. 
 
Question 6 
class Q { 
 static int m(int i) { 
 System.out.print(i + ", "); 
 return i; 
 } 
 public static void main(String s[]) { 
 int i = 1; 
 m(m(++i) + m(i++) + m(-i) + m(i++)); 
 } 
} 
What is the result of attempting to compile and run the above program? 
a. Prints: 1, 2, 3, 4, 10, 
b. Prints: 1, 2, -3, 4, 4, 
c. Prints: 2, 2, -3, -3, -2, 
d. Prints: 2, 2, -3, 3, 4, 
e. Prints: 2, 3, -3, -2, 0, 
f. Prints: 2, 3, -3, 4, 6, 
g. Prints: 2, 3, 4, 5, 14, 
h. Runtime error 
i. Compiler error 
j. None of the above 
 
Question 7 
 1. interface I1 {} 
 2. interface I2 {} 
 3. class Base implements I1 {}

Mais conteúdos dessa disciplina