KnowledgeBoat Logo

Computer Applications

Differentiate between the following:

Logical AND (&&) and Logical OR (II)

Java Operators

ICSE

65 Likes

Answer

Logical AND (&&)Logical OR(||)
It evaluates to true only if both of its operands are true.It evaluates to true if one or both of its operands are true.
Example:
int a = 8, b = 13, c = 0;
if (a < 10 && b > 10)
    c = 10;
else
    c = 5;
Here, value of c will be 5 as one of the operands is false.
Example:
int a = 8, b = 13, c = 0;
if (a > 10 || b > 10)
    c = 10;
else
    c = 5;
Here, value of c will be 10 as at least one of the operands is true.

Answered By

29 Likes