SlideShare a Scribd company logo
1 of 10
Download to read offline
qw
Basic Operators
• Java provides set of operators to manipulate values. Such as,
1. Arithmetic Operator
2. Relational Operator
3. Bitwise Operator
4. Logical Operator
5. Assignment Operator
6. Misc Operator
youtube: Zooming | https://github.com/Soba-Arjun/
Basic Operator – Arithmetic Operators
• It is used in mathematical expressions and algebra.
youtube: Zooming | https://github.com/Soba-Arjun/
a=10, b=20
Addition: a + b = 30
Subtraction: a - b = 20
Multiplication: a * b = 200
Division: a / b = 2
Modulus: a % b = 0
Increment: b++ = 21
Decrement: b-- = 19
Basic Operator – Relational Operators
• It compare 2 variables.
youtube: Zooming | https://github.com/Soba-Arjun/
a=10, b=20
Equal to: a == b : true
Not equal to: a != b : false
Greater than: a > b : false
Less than: a < b : true
Greater than or equal to: a >= b : false
Less than or equal to: a <= b : true
Basic Operator – Bitwise Operators
• Can be applied to the integer types, long, int, short, char, and byte.
• Performs bit-by-bit operation
• Bitwise operator works on bits
youtube: Zooming | https://github.com/Soba-Arjun/
Basic Operator – Bitwise Operators
youtube: Zooming | https://github.com/Soba-Arjun/
//integer format
a=60, b=13
//binary format
a=0011 1100
b=0000 1101
a&b = 0000 1100
a|b = 0011 1101
a^b = 0011 0001
~a = 1100 0011
Basic Operator – Logical Operators
• It works with Boolean values.
youtube: Zooming | https://github.com/Soba-Arjun/
a=true
b=false
Logical AND: a && b : false
Logical OR: a || b : true
Logical NOT: !(a && b) : true
Basic Operator – Assignment Operators
youtube: Zooming | https://github.com/Soba-Arjun/
Simple assignment operator: c=a+b //assign a+b to c
Add AND assignment operator: c+=a //assign c=c+a
Subtract AND assignment operator: c-=a //assign c=c-a
Multiply AND assignment operator: c*=a //assign c=c*a
Divide AND assignment operator: c/=a //assign c=c/a
Modulus AND assignment operator: c*=a //assign c=c*a
Lest shift AND assignment operator: c<<=2 //assign c=c<<2
Right shift AND assignment operator: c>>=2 //assign c=c>>2
Bitwise AND assignment operator: c&=2 //assign c=c&2
Bitwise exclusive AND assignment operator: c^=2 //assign c=c^2
Bitwise inclusive AND assignment operator: c|=2 //assign c=c|2
Basic Operator – Conditional Operators
• It is also known as ternary operator.
• This operator consists of three operands and is used to evaluate Boolean
expressions.
youtube: Zooming | https://github.com/Soba-Arjun/
variable = (expression) ? value if true : value if false;
Basic Operator – Conditional Operators
youtube: Zooming | https://github.com/Soba-Arjun/
public class Test
{
public static void main(String args[])
{
int a, b;
a = 10;
b = (a == 1) ? 20: 30;
System.out.println( "Value of b is : " + b );
}
}
Value of b is : 30

More Related Content

Similar to Java basic operators

Similar to Java basic operators (20)

C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
C++ unit-1-part-13
C++ unit-1-part-13C++ unit-1-part-13
C++ unit-1-part-13
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
05 operators
05   operators05   operators
05 operators
 
C operators
C operators C operators
C operators
 
Operator in JAVA
Operator in JAVA Operator in JAVA
Operator in JAVA
 
How NOT to build a pipeline
How NOT to build a pipelineHow NOT to build a pipeline
How NOT to build a pipeline
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
 
DSA 103 Object Oriented Programming :: Week 2
DSA 103 Object Oriented Programming :: Week 2DSA 103 Object Oriented Programming :: Week 2
DSA 103 Object Oriented Programming :: Week 2
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
Lecture-06 Operators.pdf
Lecture-06 Operators.pdfLecture-06 Operators.pdf
Lecture-06 Operators.pdf
 
B.sc CSIT 2nd semester C++ Unit4
B.sc CSIT  2nd semester C++ Unit4B.sc CSIT  2nd semester C++ Unit4
B.sc CSIT 2nd semester C++ Unit4
 
Constructor and destructors
Constructor and destructorsConstructor and destructors
Constructor and destructors
 
C# fundamentals Part 2
C# fundamentals Part 2C# fundamentals Part 2
C# fundamentals Part 2
 
Arithmetic operators
Arithmetic operatorsArithmetic operators
Arithmetic operators
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
 
C Operators
C OperatorsC Operators
C Operators
 
Lec13
Lec13Lec13
Lec13
 
Operators
OperatorsOperators
Operators
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 

More from Soba Arjun

More from Soba Arjun (20)

Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java modifiers
Java modifiersJava modifiers
Java modifiers
 
Java variable types
Java variable typesJava variable types
Java variable types
 
Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypes
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questions
 
C interview questions
C interview questionsC interview questions
C interview questions
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
 
Php interview questions with answer
Php interview questions with answerPhp interview questions with answer
Php interview questions with answer
 
Computer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary MemoryComputer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary Memory
 
Birds sanctuaries
Birds sanctuariesBirds sanctuaries
Birds sanctuaries
 
Important operating systems
Important operating systemsImportant operating systems
Important operating systems
 
Important branches of science
Important branches of scienceImportant branches of science
Important branches of science
 
Important file extensions
Important file extensionsImportant file extensions
Important file extensions
 
Java Abstraction
Java AbstractionJava Abstraction
Java Abstraction
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 
Java Overriding
Java OverridingJava Overriding
Java Overriding
 
Java Inner Classes
Java Inner ClassesJava Inner Classes
Java Inner Classes
 
java Exception
java Exceptionjava Exception
java Exception
 
Java Methods
Java MethodsJava Methods
Java Methods
 
java Inheritance
java Inheritancejava Inheritance
java Inheritance
 

Recently uploaded

Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 

Java basic operators

  • 1. qw
  • 2. Basic Operators • Java provides set of operators to manipulate values. Such as, 1. Arithmetic Operator 2. Relational Operator 3. Bitwise Operator 4. Logical Operator 5. Assignment Operator 6. Misc Operator youtube: Zooming | https://github.com/Soba-Arjun/
  • 3. Basic Operator – Arithmetic Operators • It is used in mathematical expressions and algebra. youtube: Zooming | https://github.com/Soba-Arjun/ a=10, b=20 Addition: a + b = 30 Subtraction: a - b = 20 Multiplication: a * b = 200 Division: a / b = 2 Modulus: a % b = 0 Increment: b++ = 21 Decrement: b-- = 19
  • 4. Basic Operator – Relational Operators • It compare 2 variables. youtube: Zooming | https://github.com/Soba-Arjun/ a=10, b=20 Equal to: a == b : true Not equal to: a != b : false Greater than: a > b : false Less than: a < b : true Greater than or equal to: a >= b : false Less than or equal to: a <= b : true
  • 5. Basic Operator – Bitwise Operators • Can be applied to the integer types, long, int, short, char, and byte. • Performs bit-by-bit operation • Bitwise operator works on bits youtube: Zooming | https://github.com/Soba-Arjun/
  • 6. Basic Operator – Bitwise Operators youtube: Zooming | https://github.com/Soba-Arjun/ //integer format a=60, b=13 //binary format a=0011 1100 b=0000 1101 a&b = 0000 1100 a|b = 0011 1101 a^b = 0011 0001 ~a = 1100 0011
  • 7. Basic Operator – Logical Operators • It works with Boolean values. youtube: Zooming | https://github.com/Soba-Arjun/ a=true b=false Logical AND: a && b : false Logical OR: a || b : true Logical NOT: !(a && b) : true
  • 8. Basic Operator – Assignment Operators youtube: Zooming | https://github.com/Soba-Arjun/ Simple assignment operator: c=a+b //assign a+b to c Add AND assignment operator: c+=a //assign c=c+a Subtract AND assignment operator: c-=a //assign c=c-a Multiply AND assignment operator: c*=a //assign c=c*a Divide AND assignment operator: c/=a //assign c=c/a Modulus AND assignment operator: c*=a //assign c=c*a Lest shift AND assignment operator: c<<=2 //assign c=c<<2 Right shift AND assignment operator: c>>=2 //assign c=c>>2 Bitwise AND assignment operator: c&=2 //assign c=c&2 Bitwise exclusive AND assignment operator: c^=2 //assign c=c^2 Bitwise inclusive AND assignment operator: c|=2 //assign c=c|2
  • 9. Basic Operator – Conditional Operators • It is also known as ternary operator. • This operator consists of three operands and is used to evaluate Boolean expressions. youtube: Zooming | https://github.com/Soba-Arjun/ variable = (expression) ? value if true : value if false;
  • 10. Basic Operator – Conditional Operators youtube: Zooming | https://github.com/Soba-Arjun/ public class Test { public static void main(String args[]) { int a, b; a = 10; b = (a == 1) ? 20: 30; System.out.println( "Value of b is : " + b ); } } Value of b is : 30