If Statement Without Braces
What is the output of the above code, and why?
public class SwapTest {
public static void main(String[] args) {
int x = 3, y = 5;
if(x > y)
x = y;
y = x;
System.out.println(x + " " + y);
}
}
A
Compilation error
B
5 5
C
3 3
D
3 5
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hitrishabhatia | 1 | 4 | 0m 00s | 70 |
| #2 | kazvin.tjakradinata | 1 | 2 | 0m 58s | 32 |
| #3 | y.seong2027 | 1 | 2 | 1m 36s | -6 |
| #4 | jebaksar000 | 0 | 1 | 0m 44s | -54 |
| #5 | bommasam000 | 1 | 6 | 2m 31s | -101 |
| #6 | isaact.taylor52 | 0 | 1 | 1m 50s | -120 |
| #7 | namansoin000 | 0 | 1 | 4m 00s | -250 |
| #8 | suhanakochhar006 | 1 | 4 | 8m 56s | -466 |
Items per page:
10
1 – 8 of 8
APFIVE