Page 120 - computer science (868) class 11
P. 120
Let us take an example.
When we try to change the value of the final variable in the given program, an error message is shown as “cannot
assign a value to final variable marks” and the program will not be executed.
6.2 OPERATORS
In the previous chapter, we have seen different types of operators. These operators are used for doing calculations. In
Java, there are mainly three categories of operators which are as follows:
• Unary Operator: A unary operator works only on one operand.
• Binary Operator: As the name suggests, a binary operator works on two operands.
• Ternary Operator: A ternary operator works on three operands.
While using operators, we must first understand what the operands are. The operands are the objects on which an
operation is performed. In a programming language, an operand can be a variable or a constant.
Suppose,
a + b = 5;
Here,
• a and b are operands.
• + and = are operators.
• 5 is a constant.
6.2.1 Types of Operators
There are many types of operators. They are as follows:
• Arithmetic operators • Logical operators
• Assignment operator • Shorthand operators
• Bitwise operators • Relational operators
• Conditional Assignment operators
Arithmetic Operators
An arithmetic operator is used for writing codes that perform arithmetical calculations.
118118 Touchpad Computer Science-XI

