Java Interview Questions On Operators |
9. What is the difference between the >> and >>> operators?
Ans:
The >> operator carries the sign bit when shifting right. The >>> zero-fills
bits that have been shifted out
|
10. Is sizeof a keyword?
Ans:
The sizeof operator is not a keyword
|
11. What are order of precedence and associativity, and how are they used?
Ans:
Order of precedence determines the order in which operators are evaluated in
expressions. Associatity determines whether an expression is evaluated
left-to-right or right-to-left
|
12. What is the difference between the Boolean & operator and the && operator?
Ans:
If an expression involving the Boolean & operator is evaluated, both operands
are evaluated. Then the & operator is applied to the operand. When an
expression involving the && operator is evaluated, the first operand is
evaluated. If the first operand returns a value of true then the second operand
is evaluated. The && operator is then applied to the first and second operands.
If the first operand evaluates to false, the evaluation of the second operand
is skipped.
|
13. Which Java operator is right associative?
Ans:
The = operator is right associative |
14. Can a double value be cast to a byte?
Ans:
Yes, a double value can be cast to a byte |
15. What is the % operator?
Ans:
It is referred to as the modulo or remainder operator. It returns the remainder
of dividing the first operand by the second operand.
|