Logical Operators in If Conditions
Which of the following statements best explains why the code segment below fails to compile?
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 System.out.println statement should be enclosed in braces.
B
The main method signature is invalid.
C
The if condition incorrectly uses a comma to separate boolean expressions instead of a proper logical operator.
D
The boolean variables a and b are declared in the wrong order.
Question Leaderboard
Not enough data yet to show leaderboard.
