Type Casting in Division
What is printed when the following code segment is executed?
public class Main {
public static void main(String[] args) {
int a = 7;
int b = 2;
double result = a / (double) b;
System.out.println(result);
}
}
A
Runtime Error
B
3.5
C
3.0
D
3
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | anusha.ghadge | 1 | 1 | 0m 00s | 100 |
| #2 | ravi.palepu | 1 | 1 | 0m 00s | 100 |
| #3 | songqiuhui2012 | 1 | 1 | 0m 04s | 96 |
| #4 | patrickmeijer009 | 1 | 1 | 0m 12s | 88 |
| #5 | 7017046 | 1 | 1 | 0m 18s | 82 |
| #6 | leftoverjluck | 1 | 1 | 0m 21s | 79 |
| #7 | 108185265 | 1 | 1 | 0m 43s | 57 |
| #8 | y.seong2027 | 1 | 1 | 0m 44s | 56 |
| #9 | lsj08030922 | 1 | 2 | 1h 59m | -7,063 |
APFIVE