Your SlideShare is downloading. ×
0
Various types of operators                             1
ObjectivesOn completion of this period, you would be able to    know:•   Various operators in Java                        ...
Recap•   What is an array•   What is one dimensional array•   What is two dimensional array                               ...
Operators•   An operator performs an operation on data items    (also known as operands)•   Java operators can be classifi...
Contd..             Operators•   Assignment operators•   Increment/Decrement operators•   Conditional operators•   Bit-wis...
Arithmetic Operators•   Java provides all the basic arithmetic operators    like + , - , * , / , %•   These can operate on...
Contd..             Arithmetic Operators•   We can not use these operators on boolean data    type          eg. : These ar...
Relational Operators•   These operators are used for compare two    quantities•   Java supports the following relational o...
Contd..               Relational Operators•   The syntax for relational operator is    Expression1 <relational operator> E...
Contd..            Relational Operators•   When arithmetic expressions are used , it must be    evaluated first and then r...
Logical Operators•   Java has three logical operators              &&                - Logical AND               ||       ...
Contd..               Logical Operators•   An expression which combines two or more    relational expressions•   It is cal...
Assignment Operator•   These are used to assign the value of an    expression to a variable•   The assignment operator is ...
Contd..             Assignment Operator•   These operators are used for shorthand assignment    in the following form     ...
Contd..          Assignment Operator•   The above form is equivalent to    V = V op value;    eg. : a+ = 1 means a= a+1   ...
Contd..              Assignment Operator•   Advantages of shorthand assignment operators are    •   What appears on the le...
Increment/Decrement Operators•   Java has two useful operators•   These are increment(++) and decrement(--)    operators.•...
Contd..          Increment/Decrement Operators•   Both are unary operators and these are in different    forms.    eg. : +...
Contd..        Increment/Decrement Operators•   The difference occurs only the operator is a part of    another expression...
Conditional Operator•   The character pair ‘?:’ is a ternary operator    available in Java•   This operator is used to con...
Contd..               Conditional Operator•   Here, ?: works as follows•   Expression1 is evaluated first if it is true•  ...
Contd..               Conditional Operator•   If Expression1 is false, Expression3 is evaluated•   And its value becomes t...
Bitwise Operators•   Java has a distinction of      supporting special    operators known as ‘Bitwise Operators’•   These ...
Contd..                  Bitwise Operators•   These operators are used for testing the bits or    shifting them to the rig...
Contd..                   Bitwise Operators•   The bitwise operators are        &                  Bitwise AND         |  ...
Special Operators•   Java supports some special operators•   Such as ‘ instanceOf ‘ operator•   And ‘Dot’ operator or memb...
instanceOf Operator•   The instanceOf operator is an object reference    operator•   It returns true if the object on the ...
Contd..                instanceOf Operator•   This operator allows us to determine the object    belongs to a particular c...
Dot Operator•   The Dot operator is used to access the instance of    variables and methods of a class                  eg...
Summary•   Different types of Operators                                   30
Quiz1.An Operator Operates______a)   Variablesb)   Operatorsc)   Operandsd)   All the Above                               31
Frequently Asked Questions•   List any Three Logical operator•   List any Four Bitwise Operators•   Explain various operat...
 swingsStruts                      jdbchibernatehomejava previous question papers OCT/NOV-2012 QUESTION PAPERApril / May 2...
Upcoming SlideShare
Loading in...5
×

9 cm604.10

146

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
146
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "9 cm604.10"

  1. 1. Various types of operators 1
  2. 2. ObjectivesOn completion of this period, you would be able to know:• Various operators in Java 2
  3. 3. Recap• What is an array• What is one dimensional array• What is two dimensional array 3
  4. 4. Operators• An operator performs an operation on data items (also known as operands)• Java operators can be classified as follows • Arithmetic operators • Relational operators • Logical operators 4
  5. 5. Contd.. Operators• Assignment operators• Increment/Decrement operators• Conditional operators• Bit-wise operators• Special operators 5
  6. 6. Arithmetic Operators• Java provides all the basic arithmetic operators like + , - , * , / , %• These can operate on any built in numeric data types like any other languages 6
  7. 7. Contd.. Arithmetic Operators• We can not use these operators on boolean data type eg. : These are used as a+b , a-b , a*b , a/b , a% b• Here a, b are variables or constants known as operands 7
  8. 8. Relational Operators• These operators are used for compare two quantities• Java supports the following relational operators• < , <= , > , >= , = = , !=• The value of the relational expression is either true or false 8
  9. 9. Contd.. Relational Operators• The syntax for relational operator is Expression1 <relational operator> Expession2• Here, Expression1 and Expression2 are arithmetic expressions 9
  10. 10. Contd.. Relational Operators• When arithmetic expressions are used , it must be evaluated first and then results compared. eg. : a<b a<=b a>b a>=b a= = b a!=b 10
  11. 11. Logical Operators• Java has three logical operators && - Logical AND || - Logical OR ! - Logical NOT 11
  12. 12. Contd.. Logical Operators• An expression which combines two or more relational expressions• It is called as logical expression or compound expression eg. : a >b && c <d• The logical expression given above is true only if both conditions are true• If either of them are false the expression is false 12
  13. 13. Assignment Operator• These are used to assign the value of an expression to a variable• The assignment operator is ‘= ‘ 13
  14. 14. Contd.. Assignment Operator• These operators are used for shorthand assignment in the following form V op = value;• Here, V is variable ,op is operator. eg. : a+ = 9; 14
  15. 15. Contd.. Assignment Operator• The above form is equivalent to V = V op value; eg. : a+ = 1 means a= a+1 15
  16. 16. Contd.. Assignment Operator• Advantages of shorthand assignment operators are • What appears on the left hand side need not be repeated and therefore it becomes easier • The statement is more easier to read 16
  17. 17. Increment/Decrement Operators• Java has two useful operators• These are increment(++) and decrement(--) operators.• The operator ++ adds one to the operand and the operator -- subtracts one 17
  18. 18. Contd.. Increment/Decrement Operators• Both are unary operators and these are in different forms. eg. : ++m or m++ ,this is equivalent to m+1 --m or m-- ,this is equivalent to m-1 18
  19. 19. Contd.. Increment/Decrement Operators• The difference occurs only the operator is a part of another expression eg. : m = 9, k =++ m ;• In this case the value of k would be 10 eg. : m = 9, k = m++ ;• In this case the value of k would be 9 and m would be 10 19
  20. 20. Conditional Operator• The character pair ‘?:’ is a ternary operator available in Java• This operator is used to construct conditional expressions of the form Expression1 ? Expression2 : Expression3 ; 20
  21. 21. Contd.. Conditional Operator• Here, ?: works as follows• Expression1 is evaluated first if it is true• Then the Expression2 is evaluated and becomes the value of the conditional expression 21
  22. 22. Contd.. Conditional Operator• If Expression1 is false, Expression3 is evaluated• And its value becomes the value of the conditional expression eg. : x = (a > b ) ? a : b; 22
  23. 23. Bitwise Operators• Java has a distinction of supporting special operators known as ‘Bitwise Operators’• These manipulate data at values of bit level 23
  24. 24. Contd.. Bitwise Operators• These operators are used for testing the bits or shifting them to the right or left• Bitwise operators may not be applied to float or double 24
  25. 25. Contd.. Bitwise Operators• The bitwise operators are & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR ~ Ones complement << Shift left >> Shift right >>> Shift right with zero fill 25
  26. 26. Special Operators• Java supports some special operators• Such as ‘ instanceOf ‘ operator• And ‘Dot’ operator or member selection operators 26
  27. 27. instanceOf Operator• The instanceOf operator is an object reference operator• It returns true if the object on the left hand side is an instance of the class given on the right hand side 27
  28. 28. Contd.. instanceOf Operator• This operator allows us to determine the object belongs to a particular class or not eg. : s instanceof Student;• The above statement is true if the object belongs to the class Student• Otherwise it is false 28
  29. 29. Dot Operator• The Dot operator is used to access the instance of variables and methods of a class eg. : a.dispaly();• It is also used to access classes and sub packages from packages 29
  30. 30. Summary• Different types of Operators 30
  31. 31. Quiz1.An Operator Operates______a) Variablesb) Operatorsc) Operandsd) All the Above 31
  32. 32. Frequently Asked Questions• List any Three Logical operator• List any Four Bitwise Operators• Explain various operators available in Java 32
  33. 33.  swingsStruts  jdbchibernatehomejava previous question papers OCT/NOV-2012 QUESTION PAPERApril / May 2012 c-09October/ November-2011 c-09April/ May 2011 c-09April/ May 2011 c-05 Home 33
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×