Short-Circuit Evaluation with Logical OR
What is printed when the following code segment is executed?
public class Main {
public static void main(String[] args) {
int a = 3, b = 5;
if(a < b || a++ > 3)
System.out.println(a);
else
System.out.println(b);
}
}
A
5
B
Compilation Error
C
4
D
3
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kazvin.tjakradinata | 3 | 3 | 0m 44s | 256 |
| #2 | dobaonam8386 | 2 | 2 | 0m 38s | 162 |
| #3 | lukeydragon27 | 1 | 1 | 0m 00s | 100 |
| #4 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #5 | chunxiangxu.cxu | 1 | 1 | 0m 15s | 85 |
| #6 | 27patelp | 1 | 1 | 0m 18s | 82 |
| #7 | namansoin000 | 1 | 1 | 0m 28s | 72 |
| #8 | psak12 | 1 | 1 | 0m 56s | 44 |
| #9 | thuyjerry | 0 | 1 | 0m 05s | -15 |
| #10 | y.seong2027 | 1 | 3 | 3m 21s | -121 |
Items per page:
10
1 – 10 of 12
APFIVE