| preferred AP College board partner for AP classes
easy Solved by 2 students
Logical Error In Range Check
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy