Object Oriented Programming
By
S.V.V.D.Jagadeesh
Sr. Assistant Professor
Dept of Artificial Intelligence & Data Science
LAKIREDDY BALI REDDY COLLEGE OF ENGINEERING
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Previous Discussion
LBRCE
OOP
At the end of this session, Student will be able to:
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Session Outcomes
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Operators
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Arithmetic Operators
Operator | Description | Example |
+ | Addition | int i = 8 + 9; byte b = (byte) 5+4; |
- | Subtraction | int i = 9 – 4; |
* | Multiplication | int i = 8 * 6; |
/ | Division | int i = 10 / 2; |
% | Remainder | int i = 10 % 3; |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Assignment Operators
Operator | Description | Example |
= | Assignment | int i = 10; int j = i; |
+=,-=,&=,<<= etc | Short-Hand Assignment | int a=10; a+=10; |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Relational/Equality Operators
Operator | Description | Example |
> | Greater than | if ( x > 4) |
< | Less than | if ( x < 4) |
>= | Greater than or equal to | if ( x >= 4) |
<= | Less than or equal to | if ( x <= 4) |
Operator | Description | Example |
== | Equality | If (i==1) |
!= | Non equality | If (i != 4) |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Logical Operators
Operator | Description | Example |
&& | Logical and | If (a == 4 && b == 5) |
|| | Logical or | If (a == 4 || b == 5) |
! | Logical Not | If (!a) |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Bitwise and Shift Operators
Operator | Description | Example |
& | Bitwise and | 001 & 111 = 1 |
| | Bitwise or | 001 | 110 = 111 |
^ | Bitwise ex-or | 001 ^ 110 = 111 |
~ | Reverse | ~011 = -10 |
Operator | Description | Example |
>> | Right shift | 4 >> 1 = 100 >> 1 = 010 = 2 |
<< | Left Shift | 4 << 1 = 100 << 1 = 1000 = 8 |
>>> | Unsigned Right shift | 4 >>> 1 = 100 >>> 1 = 010 = 2 |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
instance of operator
Operator | Description | Example |
instanceof | Instamce of | If (john instance of person) |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Precedence & Associativity of Operators
Category | Operators | Associativity |
Parantheses | () | Left to right |
Postfix | ++ - - | Left to right |
Unary | + - ! ~ ++ - - | Right to left |
Multiplicative | * / % | Left to right |
Additive | + - | Left to right |
Shift | << >> | Left to right |
Relational | < <= > >= | Left to right |
Equality | == != | Left to right |
Bitwise AND | & | Left to right |
Bitwise XOR | ^ | Left to right |
Bitwise OR | | | Left to right |
Logical AND | && | Left to right |
Logical OR | || | Left to right |
Conditional | ?: | Right to left |
Assignment | = += -= *= /= %=>>= <<= &= ^= |= | Right to left |
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Assignment
LBRCE
OOP
S.V.V.D.Jagadeesh
Thursday, August 31, 2023
Summary
LBRCE
OOP