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.
14. RELATIONAL OPERATORS:
● < - lesser than
● > - greater than
● <= - lesser than or equal to
● >= - greater than or equal to
● == - equal to
● != - not equal to
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
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
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);