मराठी

Explain the following operator with an example program: Logical Operator

Advertisements

प्रश्न

Explain the following operator with an example program:

Logical Operator

कोड लेखन
स्पष्ट करा
Advertisements

उत्तर

A Logical Operator in Java is used to combine or reverse Boolean expressions and returns a Boolean value, either true or false.

The logical operators in Java are Logical AND (&&), Logical OR (||) and Logical NOT (!).

Example:

class LogicalOperator
{
    public static void main(String[] args)
    {
        int a = 10, b = 20;
        System.out.println((a < b) && (a > 5));
        System.out.println((a > b) || (a < 15));
        System.out.println(!(a < b));
    }
}

Output:

true
true
false
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×