Mixed Type Arithmetic
A sequence of operations uses explicit type casting between double and int types to compute a final integer result.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
double x = 7.9;
int y = 3;
int z = (int) x + y;
double res = (double) (z / y) + x;
System.out.println((int) res);
}
}
A
11
B
12
C
9
D
10
Question Leaderboard
Not enough data yet to show leaderboard.
