SlideShare a Scribd company logo
OPERATORS
What is operators?
● Operators are predefined symbol which is used to perform some
specific task on the given data.the data given as a input to the
operator is known as operand.
TYPES OF OPERATORS BASED ON OPERAND:
● UNARY OPERATOR
● BINARY OPERATOR
● TERNARY OPERATOR
UNARY OPERATOR :
The operator which can accept only one operand
is known as unary operator.
Example : Increment/Decrement operator.
BINARY OPERATOR:
The operator which can accept two operand is known
as binary operator.
Example : Arithmetic operator,relational operators.
TERNARY OPERATOR:
The operator which can accept three operand is
known as ternary operator.
Example : Conditional Operator
CLASSIFICATION OF OPERATOR BASED ON TASK:
● ARITHMETIC OPERATOR
● ASSIGNMENT OPERATOR
● RELATIONAL OPERATOR
● LOGICAL OPERATOR
● INCREMENT/DECREMENT OPERATOR
● CONDITIONAL OPERATOR
MISCELLANEOUS
ARITHMETIC OPERATOR
‘+’ Operator:
+
ADDITION
CONCAT
ACTIVITY:
1.Write a java program to perform addition of two numbers.
2.Write a java program to concat a number and String.
3.Write a java program to concat a floating number and String.
4.Write a java program to concat a integer and character.
5.Write a java program to concat a character and String.
6.Write a java program to concat a integer,character,boolean and
String data.
10)OPERATORS.pdf
ASSIGNMENT OPERATOR:
Assignment operators are used in Java to assign values to variables.
1. +=
2. -=
3. *=
4. /=
Operator Example Equivalent to
= a=b; a=b;
+= a+=b; a=a+b;
- -= a-=b; a=a-b;
Operator Example Equivalent to
*= a*=b; a=a*b;
/= a/=b; a=a/b;
%= a%=b; a=a%b;
RELATIONAL OPERATORS:
● < - lesser than
● > - greater than
● <= - lesser than or equal to
● >= - greater than or equal to
● == - equal to
● != - not equal to
NOTE :
The return value of relational operator is boolean.
LOGICAL OPERATOR:
&&(Logical AND)
If all the expression returns true then this operator will
return true
||(Logical OR)
If any of one of the expression return true then this operator
will return true
! (Logical NOT)
It the result is true then it will return false and vice versa
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE
AND TABLE :
OR TABLE :
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE
INCREMENT/DECREMENT OPERATOR
Increment Operator:
● Pre-Increment Operator
● Post-Increment Operator
Decrement Operator:
● Pre-Decrement Operator
● Post-Decrement Operator
INCREMENT OPERATOR
PRE-INCREMENT (++VAR) POST-INCREMENT(VAR++)
● INCREMENT THE
VALUE BY 1
● USE THE
UPDATED VALUE
● USE THE OLD
DATA
● INCREMENT THE
VALUE BY 1
DECREMENT OPERATOR
PRE- DECREMENT(--VAR) POST- DECREMENT(VAR- -)
● DECREMENT THE
VALUE BY 1
● USE THE
UPDATED VALUE
● USE THE OLD
DATA
● DECREMENT THE
VALUE BY 1
Conditional Operator:
SYNTAX:
Operand 1 ? Operand 2 : Operand 3
(Condition) ? value1 : value2
Working of Conditional Operator:
CONDITION ? VALUE1 VALUE2
:
TRUE
FALSE
● Conditional Operator will check the condition,if
condition is true operand 2 will gets executed,if
condition is false operand 3 ill gets executed.
Note :
● The return value of conditional operator is always
boolean.
● The return value of operand 1 is based on operand
2 and operand 3.
EXAMPLE:
Class Demo
{
public static void main(String[] args)
{
int a = 10;
int b =20;
int c = (a>b) ? a : b; //Conditional Operator
System.out.println(c); // 20
}
}
10)OPERATORS.pdf
TRACE THE PROGRAMS: (INCREMENT OPERATOR)
1.int a=10;
a++;
s.o.p(a);
2.int b =20;
++b;
s.o.p(b);
3.int a=10;
a=a++;
s.o.p(a);
4.int d =40;
int e = 50;
d = d++ + ++e;
s.o.p(d);
5.short s = 20;
byte b = 25;
s++;
++b;
s.o.p(s+b);
6. int a1=100;
short a2 = 150;
int a3 = 350;
long a4 = 200;
long res = a1++ - ++a2 +a3++ - ++a4;
s.o.p(res);
1.int a=35;
a - - ;
s.o.p(a);
2.int b = 70;
- -b;
s.o.p(b);
TRACE THE PROGRAMS: (DECREMENT OPERATOR)
3.int a=100;
a= a- -;
s.o.p(a);
4.int d =76;
int e = 32;
d = d- - + - -e;
s.o.p(d);
5. int a1=100;
short a2 = 150;
int a3 = 350;
long a4 = 200;
int res = a1- - - ++a2 + a3- - - ++a4;
s.o.p(res);

More Related Content

PPTX
Operators
PPTX
Operators in java
PDF
Java 2
PPTX
PPT
operators.ppt
PPT
Shubhrat operator &amp; expression
PPTX
Opeartor &amp; expression
PPTX
Operator in JAVA
Operators
Operators in java
Java 2
operators.ppt
Shubhrat operator &amp; expression
Opeartor &amp; expression
Operator in JAVA

Similar to 10)OPERATORS.pdf (20)

PDF
itft-Operators in java
PPTX
Java Operators with Simple introduction.pptx
PPTX
Logical Operators C/C++ language Programming
DOCX
Operators
PPTX
OOPJ_PPT2,JAVA OPERATORS TPYE WITH EXAMPLES.pptx
PPTX
Java Operators with Simple introduction.pptx
PDF
5_Operators.pdf
PPTX
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES
PDF
Operators in java
PPTX
presentation on array java program operators
PPTX
Oop using JAVA
PPT
4_A1208223655_21789_2_2018_04. Operators.ppt
PDF
Java basic operators
PDF
Java basic operators
PPT
Java Operators.ppt
PPTX
OPERATORS OF C++
PPTX
Pj01 4-operators and control flow
PPTX
11operator in c#
PPT
9 cm604.10
PPTX
Operators in java presentation
itft-Operators in java
Java Operators with Simple introduction.pptx
Logical Operators C/C++ language Programming
Operators
OOPJ_PPT2,JAVA OPERATORS TPYE WITH EXAMPLES.pptx
Java Operators with Simple introduction.pptx
5_Operators.pdf
PPT ON JAVA AND UNDERSTANDING JAVA'S PRINCIPLES
Operators in java
presentation on array java program operators
Oop using JAVA
4_A1208223655_21789_2_2018_04. Operators.ppt
Java basic operators
Java basic operators
Java Operators.ppt
OPERATORS OF C++
Pj01 4-operators and control flow
11operator in c#
9 cm604.10
Operators in java presentation
Ad

Recently uploaded (20)

PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Website Design Services for Small Businesses.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
assetexplorer- product-overview - presentation
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
AutoCAD Professional Crack 2025 With License Key
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Advanced SystemCare Ultimate Crack + Portable (2025)
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
17 Powerful Integrations Your Next-Gen MLM Software Needs
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Website Design Services for Small Businesses.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
assetexplorer- product-overview - presentation
CHAPTER 2 - PM Management and IT Context
Design an Analysis of Algorithms I-SECS-1021-03
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Weekly report ppt - harsh dattuprasad patel.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Monitoring Stack: Grafana, Loki & Promtail
Designing Intelligence for the Shop Floor.pdf
Computer Software and OS of computer science of grade 11.pptx
Ad

10)OPERATORS.pdf

  • 2. What is operators? ● Operators are predefined symbol which is used to perform some specific task on the given data.the data given as a input to the operator is known as operand. TYPES OF OPERATORS BASED ON OPERAND: ● UNARY OPERATOR ● BINARY OPERATOR ● TERNARY OPERATOR
  • 3. UNARY OPERATOR : The operator which can accept only one operand is known as unary operator. Example : Increment/Decrement operator.
  • 4. BINARY OPERATOR: The operator which can accept two operand is known as binary operator. Example : Arithmetic operator,relational operators.
  • 5. TERNARY OPERATOR: The operator which can accept three operand is known as ternary operator. Example : Conditional Operator
  • 6. CLASSIFICATION OF OPERATOR BASED ON TASK: ● ARITHMETIC OPERATOR ● ASSIGNMENT OPERATOR ● RELATIONAL OPERATOR ● LOGICAL OPERATOR ● INCREMENT/DECREMENT OPERATOR ● CONDITIONAL OPERATOR MISCELLANEOUS
  • 9. ACTIVITY: 1.Write a java program to perform addition of two numbers. 2.Write a java program to concat a number and String. 3.Write a java program to concat a floating number and String. 4.Write a java program to concat a integer and character. 5.Write a java program to concat a character and String. 6.Write a java program to concat a integer,character,boolean and String data.
  • 11. ASSIGNMENT OPERATOR: Assignment operators are used in Java to assign values to variables. 1. += 2. -= 3. *= 4. /=
  • 12. Operator Example Equivalent to = a=b; a=b; += a+=b; a=a+b; - -= a-=b; a=a-b;
  • 13. Operator Example Equivalent to *= a*=b; a=a*b; /= a/=b; a=a/b; %= a%=b; a=a%b;
  • 14. RELATIONAL OPERATORS: ● < - lesser than ● > - greater than ● <= - lesser than or equal to ● >= - greater than or equal to ● == - equal to ● != - not equal to
  • 15. NOTE : The return value of relational operator is boolean.
  • 16. LOGICAL OPERATOR: &&(Logical AND) If all the expression returns true then this operator will return true ||(Logical OR) If any of one of the expression return true then this operator will return true ! (Logical NOT) It the result is true then it will return false and vice versa
  • 17. TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE AND TABLE :
  • 18. OR TABLE : TRUE TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE
  • 19. INCREMENT/DECREMENT OPERATOR Increment Operator: ● Pre-Increment Operator ● Post-Increment Operator Decrement Operator: ● Pre-Decrement Operator ● Post-Decrement Operator
  • 20. INCREMENT OPERATOR PRE-INCREMENT (++VAR) POST-INCREMENT(VAR++) ● INCREMENT THE VALUE BY 1 ● USE THE UPDATED VALUE ● USE THE OLD DATA ● INCREMENT THE VALUE BY 1
  • 21. DECREMENT OPERATOR PRE- DECREMENT(--VAR) POST- DECREMENT(VAR- -) ● DECREMENT THE VALUE BY 1 ● USE THE UPDATED VALUE ● USE THE OLD DATA ● DECREMENT THE VALUE BY 1
  • 22. Conditional Operator: SYNTAX: Operand 1 ? Operand 2 : Operand 3 (Condition) ? value1 : value2
  • 23. Working of Conditional Operator: CONDITION ? VALUE1 VALUE2 : TRUE FALSE
  • 24. ● Conditional Operator will check the condition,if condition is true operand 2 will gets executed,if condition is false operand 3 ill gets executed. Note : ● The return value of conditional operator is always boolean. ● The return value of operand 1 is based on operand 2 and operand 3.
  • 25. EXAMPLE: Class Demo { public static void main(String[] args) { int a = 10; int b =20; int c = (a>b) ? a : b; //Conditional Operator System.out.println(c); // 20 } }
  • 27. TRACE THE PROGRAMS: (INCREMENT OPERATOR) 1.int a=10; a++; s.o.p(a); 2.int b =20; ++b; s.o.p(b); 3.int a=10; a=a++; s.o.p(a); 4.int d =40; int e = 50; d = d++ + ++e; s.o.p(d);
  • 28. 5.short s = 20; byte b = 25; s++; ++b; s.o.p(s+b); 6. int a1=100; short a2 = 150; int a3 = 350; long a4 = 200; long res = a1++ - ++a2 +a3++ - ++a4; s.o.p(res);
  • 29. 1.int a=35; a - - ; s.o.p(a); 2.int b = 70; - -b; s.o.p(b); TRACE THE PROGRAMS: (DECREMENT OPERATOR) 3.int a=100; a= a- -; s.o.p(a); 4.int d =76; int e = 32; d = d- - + - -e; s.o.p(d);
  • 30. 5. int a1=100; short a2 = 150; int a3 = 350; long a4 = 200; int res = a1- - - ++a2 + a3- - - ++a4; s.o.p(res);