0% found this document useful (0 votes)
7 views

Lecture 3 Operators in JAVA - Part 2

The document discusses types of operators in Java including arithmetic, assignment, comparison, and logical operators. It focuses on logical operators like AND, OR, and NOT and explains the differences between short-circuit and non-short-circuit versions of these operators.

Uploaded by

Khunsha farooq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture 3 Operators in JAVA - Part 2

The document discusses types of operators in Java including arithmetic, assignment, comparison, and logical operators. It focuses on logical operators like AND, OR, and NOT and explains the differences between short-circuit and non-short-circuit versions of these operators.

Uploaded by

Khunsha farooq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

JAVA Programming (CST015)

Lecture 3: Operators in JAVA (PART-2)

Department of Computer Science and Engineering


National Institute of Technology, Srinagar, Jammu and Kashmir
March 13, 2023
Types of Operators in Java

• Arithmetic Operators: [+, -, *, /, %, ++, --]


• Assignment Operators: [=, +=]
• Comparison Operators: [==, >=, <=]
• Logical Operators: [&&, ||, !]
Logical Operators

• Logical Operators: [&&, ||, !]


Logical operators are used to check for two or more condition.
Output of Logical operators are always some Boolean value.

& or && : called as AND operator.


| or || : called as OR operator
!: called as NOT Operator
& or && : called as AND operator.

The output of AND operator is True only if all the conditions are true.

Difference between & and &&


&& is called as short circuit AND in which if one condition is False, it will
not check the remaining conditions and gives the O/P False.

In case of & operator, even if initial condition is False, it will still check
for the remaining conditions.
| or || : called as OR operator.
| or || : called as OR operator.

The output of OR operator is True if any one condition is true.

Difference between | And ||


|| is called as short circuit OR in which if the initial condition is True, it will
not check the remaining conditions and gives the O/P True.

In case of | operator, all conditions are checked even if the initial condition is
True.

You might also like