SlideShare a Scribd company logo
1 of 30
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.
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
}
}
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

Similar to 10)OPERATORS.pdf (20)

OCA JAVA - 3 Programming with Java Operators
 OCA JAVA - 3 Programming with Java Operators OCA JAVA - 3 Programming with Java Operators
OCA JAVA - 3 Programming with Java Operators
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)
 
Operators in C#
Operators in C#Operators in C#
Operators in C#
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Chapter 8 Operators and Expressions.pptx
Chapter 8 Operators and Expressions.pptxChapter 8 Operators and Expressions.pptx
Chapter 8 Operators and Expressions.pptx
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
JavaScript operators
JavaScript operatorsJavaScript operators
JavaScript operators
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
Opeartor &amp; expression
Opeartor &amp; expressionOpeartor &amp; expression
Opeartor &amp; expression
 
Object Oriented Programming using C++ - Part 3
Object Oriented Programming using C++ - Part 3Object Oriented Programming using C++ - Part 3
Object Oriented Programming using C++ - Part 3
 
Chap 3(operator expression)
Chap 3(operator expression)Chap 3(operator expression)
Chap 3(operator expression)
 
Operator in C language
Operator in C languageOperator in C language
Operator in C language
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptx
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptx
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
JavaScript Operators
JavaScript OperatorsJavaScript Operators
JavaScript Operators
 
Chapter 3 dti2143
Chapter 3 dti2143Chapter 3 dti2143
Chapter 3 dti2143
 
Oops
OopsOops
Oops
 

Recently uploaded

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

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.
  • 10.
  • 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 } }
  • 26.
  • 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);