Operators
Operators
Ans: A operator is a special symbol that tells the compiler to perform specific
mathematical or logical operations. It is generally used in a program to perform a
particular function on operands.
2. What are the types of operators based on the number of operands?
Ans: There are three types of operators in java based on the number of operands.
They are:
Unary operator -- Operators that acts on single operand.
Binary operator -- Operators that acts on two operands.
Ternary operator -- Operators that acts on three operands.
3. What is Expression in Java?
Ans: An expression in java is a combination of operators and operands that is used to
perform mathematical or logical calculations. In simple words, it is a combination of
variables, constants, and operators.
4. What are the types of operators?
Ans: There are two types of operators
Symbolic Operator
Named Operator
Symbolic Operator:
If a symbol like +, -, * etc. is used as an operator, it is called symbolic operator.
There are mainly eight types of operators based on symbols. They are as follows:
Arithmetic operators ⇒ +, -, *, /, etc.
Relational operators ⇒ <, >, <=, >=, = =,!=
Logical operators ⇒ &&, ||,!
Assignment operators ⇒ =,
Increment and decrement operators ⇒ + +, – –
Conditional operators ⇒ ?:
Bitwise operators ⇒ &,!, ^, ~, <<, >>, >>>
Shift operators ⇒ <<, >>, >>>.
Named Operator:
If a keyword is used as an operator, it is called named operator. The named operator
is instance of.
Instance of - The instance of keyword checks whether an object is an instance of a
specific class or an interface. The instance of keyword compares the instance with
type. The return value is either true or false.