double d = 9.7;
int i = (int) d;
System.out.println(i);What is printed?
- Acheck_circle
9
- B
10
- C
9.7
- D
9.0
Explanation
Casting a double to an int truncates the decimal portion (it does not round), so 9.7 becomes 9.
AP Computer Science A· difficulty 3/5
double d = 9.7;
int i = (int) d;
System.out.println(i);What is printed?
9
10
9.7
9.0
Explanation
Casting a double to an int truncates the decimal portion (it does not round), so 9.7 becomes 9.
Want 10 more like this — adaptive to your weak spots?