Explain the Various Types of Operators in Java.
Advertisements
Question
Explain the Various Types of Operators in Java.
Explain
Advertisements
Solution
- Arithmetic Operators: These operators are used to perform mathematical operations such as addition, subtraction, multiplication, division and modulus.
Examples:+,-,*,/,%. - Relational Operators: These operators are used to compare two values or expressions. They return a Boolean result, either
trueorfalse. Examples:==,!=,>,<,>=,<=. - Logical Operators: These operators are used to combine or reverse Boolean expressions and conditions.
Examples:&&(AND),||(OR),!(NOT). - Assignment Operators: These operators are used to assign values to variables and perform operations while assigning values.
Examples:=,+=,-=,*=,/=,%=. - Unary Operators: These operators perform operations on a single operand. They are used to increase, decrease or change the sign of a value.
Examples:++,--,+,-,!. - Bitwise Operators: These operators are used to perform operations on the individual bits of integer values.
Examples:&,|,^,~. - Shift Operators: These operators are used to shift the bits of an integer value to the left or right.
Examples:<<,>>,>>>. - Conditional (Ternary) Operator: This operator is used to select one of two values based on a condition. It uses the symbols
?and:. - instanceof Operator: This operator is used to check whether an object is an instance of a particular class or interface. It returns a Boolean value, either
trueorfalse.
shaalaa.com
Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 131]
