In Dan Chisholm's java.lang.Math topic exam,
question #8 looks like this
class C {
public static void main (
String[] args) {
int i1 = Math.round(0.5f);
int i2 = Math.round(1.5f);
System.out.print(i1 + "," + i2);
}
}
What is the result of attempting to compile and run the program?
a. Prints: 0.0,1.0
b. Prints: 0.0,2.0
c. Prints: 1.0,1.0
d. Prints: 1.0,2.0
e. Compiler Error
f. Runtime Error
g. None of the Above
I thought it would be g, since the return type is int and the answer would be 1,2. But the answer says d it prints 1.0, 2.0. I compiled and it executed as 1,2. Did I miss something? or is the answer wrong?
Love the topic exams, by the way. Thanks so much Dan.