Java Interview Questions - Operator
1. How may number of operators present in java?
Java supports 44 number of of operator.
2. How to convert one type to another data type and why to use explicit typecast in java?
By typecasting one type able to convert to another type. explicit typecast used to convert a higher type date to lower type.
3. What is instanceof operator?
The java instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface).
4. According to Java Operator precedence, which operator is considered to be with highest precedence?
Parenthesis () operator is operator is considered to be with highest precedence?
5. Which Java operator is right associative?
The assignment operators are right associative.
6. What is the difference between the » and »> operators?
The » operator carries the sign bit when shifting right. The »> zero-fills bits that have been shifted out.
7. What is dot operator?
Dot operator is used to access methods and variables within objects and classes. They are used to access instance members of an object and class members of a class
8. What is the difference between double and float variables in Java?
The double value we used can store really big numbers of the floating point variety. Instead of using double, float can be used. When storing a value in a float variable, you need the letter “f” at the end.
Like this:
first_number =11.3f;
second_number = 13.4f;
9. What is ternary operator?
Ternary operator is the replacement of conditional control structure. And used to check the condition.
10. What is the % operator?
It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.
11. Is &&= a valid Java operator?
No, it is not a valid operator.
12. Which operator known as type comparison operator and why?
Instanceof because this operator will check the object existence.