Logical Operators in If Conditions
What is the error that prevents this code from compiling?
public class Test {
public static void main(String[] args) {
boolean a = true, b = false;
if(a, b) {
System.out.println("Invalid operator usage");
}
}
}
A
The if condition incorrectly uses a comma to separate boolean expressions instead of a proper logical operator.
B
The main method signature is invalid.
C
The boolean variables a and b are declared in the wrong order.
D
The System.out.println statement should be enclosed in braces.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE