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.