Java If-Else If-Else Logic
What output will the code produce?
public class Main {
public static void main(String[] args) {
int x = 4;
if(x > 5) {
System.out.println("Greater than 5");
} else if(x == 5) {
System.out.println("Equal to 5");
} else {
System.out.println("Less than 5");
}
}
}
A
No output
B
Greater than 5
C
Equal to 5
D
Less than 5
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | mahmoudjibrin08 | 1 | 1 | 0m 00s | 100 |
| #2 | lsj08030922 | 1 | 1 | 0m 00s | 100 |
| #3 | psak12 | 1 | 1 | 0m 11s | 89 |
Items per page:
10
1 – 3 of 3
APFIVE