int a = 9;
int b = 4;
double r = (double)(a / b);
System.out.println(r);What is printed?
- Acheck_circle
2.0
- B
2.25
- C
2
- D
2.5
Explanation
The cast applies after the int division a / b which is 2; converting 2 to double gives 2.0.
AP Computer Science A· difficulty 3/5
int a = 9;
int b = 4;
double r = (double)(a / b);
System.out.println(r);What is printed?
2.0
2.25
2
2.5
Explanation
The cast applies after the int division a / b which is 2; converting 2 to double gives 2.0.
Want 10 more like this — adaptive to your weak spots?