Java Compound Condition Logic
The following program is intended to print Condition satisfied but instead prints Condition failed. Which statement describes the logical error in the if statement’s condition?
public class MisuseOperator {
public static void main(String[] args) {
int x = 3, y = 7;
if(x > 2 && y < 5 && x < y)
System.out.println("Condition satisfied");
else
System.out.println("Condition failed");
}
}
A
Not comparing x with another appropriate constant.
B
Checking if x equals y instead of comparing their magnitudes.
C
Using logical OR (||) instead of logical AND (&&).
D
Using “y < 5” instead of “y > 5” in the compound condition.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | theofanusmischa | 1 | 1 | 0m 00s | 100 |
| #2 | hitrishabhatia | 1 | 4 | 0m 00s | 70 |
| #3 | namansoin000 | 1 | 1 | 0m 36s | 64 |
| #4 | y.seong2027 | 1 | 1 | 0m 45s | 55 |
| #5 | suhanakochhar006 | 1 | 1 | 0m 55s | 45 |
| #6 | kazvin.tjakradinata | 1 | 1 | 1m 56s | -16 |
| #7 | chunxiangxu.cxu | 0 | 1 | 0m 37s | -47 |
| #8 | mattaana000 | 1 | 1 | 2m 37s | -57 |
| #9 | bommasam000 | 3 | 6 | 1h 03m | -3,555 |
Items per page:
10
1 – 9 of 9
APFIVE