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
true
false
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
