Logical Error In Range Check
The program is intended to check if ‘value’ lies between 5 and 10. What is the error in the boolean condition?
public class RangeCheck {
public static void main(String[] args) {
int value = 7;
if(value >= 5 && value >= 10)
System.out.println("Value is between 5 and 10");
else
System.out.println("Value is not between 5 and 10");
}
}
A
Replacing the logical AND (&&) with OR (||) in the condition.
B
Failing to include an equality check for the lower bound.
C
Declaring variable value as a byte instead of an int.
D
Using “value >= 10” instead of “value <= 10” in the condition.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE