Mixed Type Precision
Analyze how explicit casting affects the result of arithmetic expressions involving doubles and integers.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
int x = 5;
double y = 2.5;
int res = (int) (x * y) / (int) y;
System.out.print(res);
}
}
A
3
B
6
C
4
D
5
Question Leaderboard
Not enough data yet to show leaderboard.
