हिंदी

Explain the following operator with an example program: Relational Operator

Advertisements

प्रश्न

Explain the following operator with an example program:

Relational Operator

कोड लेखन
स्पष्ट कीजिए
Advertisements

उत्तर

A Relational Operator in Java is used to compare two values or expressions. It determines the relationship between them and returns a Boolean value, either true or false.

The relational operators in Java are greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), equal to (==) and not equal to (!=).

Example:

class RelationalOperator
{
    public static void main(String[] args)
    {
        int a = 10, 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 31. (b) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×