|
Home ► Placements ► Interview Questions ► Java Interview Questions And Answers ►Java Interview Questions On Operators ▼
Java Interview Questions On Operators |
1. What are all the java shift operators?
Ans:
Shift Operators are:
- l << Un-signed left shift
- l >> Signed right shift
- l >>> Un-signed right shift
When you are doing left-shift using the operator << and un-signed right-shift using operator >>>,these operators insert zeros in the new position.
The >> operator puts either zero or one depend upon the MSB (Most Significant Bit) before shifting. If MSB is one before shifting then it puts one in the new position. |
2. What are all the Java primitive data conversion rules?
Ans:
l A boolean type may not be converted to non-boolean type.
That is you cannot assign a boolean value to non-boolean type and vice versa.
l A non-boolean type may be converted to non-boolean type provided that the conversion is
widening. |
3. what are all Java possible data type assignment operations?
Ans:
- l A byte value can be assigned to short, int, long, float or double.
- l A short value can be assigned to int, long, float, double.
- l A char value can be assigned to int, long, float, double.
- l A int value can be assigned to long, float, double.
- l A long value can be assigned to float, double.
- l A float value can be assigned to double.
|
4. Explain About the instance of operator?
Ans:
This is used for Runtime Type Identification ( RTTI). It returns boolean. This can be used to test against class, interface, and an array.
The rules that returns true:
- l If the left - hand side argument is the same as or subclass of the right - hand side operand.
- l If applied to interface then the left-hand side operand should implement the right-hand side
|
|
|