Single Choice Easy

QWhich relational operator is used to check if one value is less than another in Java?

ID: #20136 Relational Operators 97 views
Question Info
#20136Q ID
EasyDifficulty
Relational OperatorsTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A <
  • B >
  • C <=
  • D >=
Correct Answer

Explanation

In Java, the less-than operator (<) is used to check if one value is less than another. It evaluates to true if the left operand is less than the right operand; otherwise, it evaluates to false.

Here's a simple example:


public class LessThanOperatorExample {
    public static void main(String[] args) {
        // Example values
        int a = 5;
        int b = 10;

        // Check if a is less than b
        if (a < b) {
            System.out.println("a is less than b.");
        } else {
            System.out.println("a is not less than b.");
        }
    }
}

In this example, since a is 5 and b is 10, the condition a < b is true, and the program prints "a is less than b."

Share This Question

Challenge a friend or share with your study group.