हिंदी

Explain the Relation Operator with the help of an example program.

Advertisements

प्रश्न

Explain the Relation Operator with the help of an example program.

स्पष्ट कीजिए
Advertisements

उत्तर

In Java, Relational Operators are used to compare two values or expressions. These operators determine the relationship between two operands and return a Boolean value, either true or false, depending on the result of the comparison.

The various relational operators in Java are:

Operator

Description

>

Greater than

<

Less than

>=

Greater than or equal to

<=

Less than or equal to

==

Equal to

!=

Not equal to

Example Program:

class RelationalOperator 
{
    public static void main(String[] args) 
    {
        int a = 10;
        int b = 20;

        System.out.println(a > b);
        System.out.println(a < b);
        System.out.println(a >= b);
        System.out.println(a <= b);
        System.out.println(a == b);
        System.out.println(a != b);
    }
}

Output:

false
true
false
true
false
true
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 6 Variables and Expressions
EXERCISE | Q 16. | पृष्ठ १३१
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×