Prévia do material em texto
Certified Java Programmer Mock Exam 20
byte b = 5;
System.out.println(b>> 1;
System.out.println(b);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: -128
b. Prints: -127
c. Prints: -1
d. Prints: 0
e. Prints: 1
f. Prints: 127
g. Prints: 128
h. Runtime Exception
i. Compiler Error
j. None of the Above
Question 6
class L {
static String m(float i) {return "float";}
static String m(double i) {return "double";}
public static void main (String[] args) {
char a = 1;
long b = 2;
System.out.print(m(a)+","+ m(b));
}
}
What is the result of attempting to compile and run the above program?
a. Prints: float,float
b. Prints: float,double
c. Prints: double,float
d. Prints: double,double
e. Compiler error.
f. Runtime error.
g. None of the Above
Question 7
class Blue {
public static void main (String[] args) {
int i1 = (Integer.MAX_VALUE + 2);
int i2 = (Integer.MIN_VALUE + 1);
int i3 = (Integer.MIN_VALUE + 2);
int i4 = (Integer.MIN_VALUE + 3);
System.out.println((i1==i2)+","+(i1 ==i3)+","+(i1 ==i4));
}
}
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
Question 8
class Beige {
public static void main (String[] args) {
int i = (int)Float.NEGATIVE_INFINITY;
int j = (int)Float.POSITIVE_INFINITY;
int k = (int)Float.NaN;
System.out.println((i == Integer.MIN_VALUE) +
", " + (j == Integer.MAX_VALUE) +