Page 57 - CA_Blue( J )_Class10
P. 57

04


                                                                         OPERATORS IN JAVA
















                           Learning Objectives



                     4.1 Operator and Operand                          4.2 Forms of Operators
                     4.3 Types of Operators                            4.4 Hierarchy of Operators






                 In your previous classes, you have learnt that operators are special symbols that are used to perform special tasks like
                 addition, subtraction, etc. In this chapter, you are going to learn more about the operators in java.


                     4.1 OPERATOR AND OPERAND
                 While developing the logic of a program, we may require some symbols to perform arithmetical or logical calculations.
                 These symbols are known as operators. Operators are used with identifiers, values and literals to form an expression.
                 Generally, an expression is made up of two parts: operand and operator.  The variables or values that are used in an
                 expression are called Operand and the symbols like + (addition), - (subtraction), etc. that perform calculations over the
                 operands are known as Operators. Java has a group of built-in operators with a  common meaning assigned to them,
                 although in some special cases it allows programmers to assign different meanings.


                                                   int a=10 , b= 6 , c;
                                                   c = a + b ;

                                                   System.out.println("The result is :"+c);


                 Here, in each line, we are using different types of operators and related operands.
                 •  In the 1st line: "=" acts as an assignment operator and "a", "b", 10 and 6 are operands.
                 •  In the 2nd line: "=" and "+" acts as an assignment and addition operators respectively and "a", "b" and "c" are
                   operands.
                 •  In the 3rd line: "+" acts as a special operator and "c" are an operand.
                 In the above example, a + b is said to be an arithmetical expression and c = a + b is said to be an arithmetical statement.

                 Arithmetical Expression: Any meaningful statement containing identifiers, literals, and arithmetical operators that
                 produces a result is called an arithmetical expression. For example: a * b and 2 * (l + b).





                                                                                                                       55
                                                                                                      Operators in Java   55
   52   53   54   55   56   57   58   59   60   61   62