If Else Statement Syntax Error
Which of the following best describes the compilation error in the code segment below?
public class Test {
public static void main(String[] args) {
if(5 > 3)
System.out.println("Hello");
else
System.out.println("World")
}
}
A
The else block must be enclosed in curly braces.
B
The statement in the else block is missing a semicolon at the end.
C
The main method’s return type is declared incorrectly.
D
The if condition is written with an incorrect relational operator.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kazvin.tjakradinata | 1 | 1 | 0m 06s | 94 |
| #2 | y.seong2027 | 1 | 1 | 0m 08s | 92 |
| #3 | namansoin000 | 1 | 1 | 0m 25s | 75 |
| #4 | hitrishabhatia | 1 | 4 | 0m 00s | 70 |
| #5 | chunxiangxu.cxu | 0 | 1 | 59m 54s | -3,604 |
| #6 | bommasam000 | 2 | 3 | 18h 01m | -64,678 |
Items per page:
10
1 – 6 of 6
APFIVE