Answers:
In Java, each operator has an associated precedence which helps to evaluate an expression if more than one operator is used. The evaluation of an operator depends on the basis of the operator precedence. The operators at the higher level of precedence are evaluated first and operators of same precedence are evaluated either from left to right or vice-versa. Such a property of an operator is known as associativity.
Table describes the operator precedence and its associativity:
Order
|
Operator
|
Associativity
|
1
|
()
[]
|
Left to Right
|
2
|
Unary Plus
(Unary Minus)
++
--
!
~
|
Right to Left
|
3
|
*
/
%
|
Left to Right
|
4
|
+
(Subtraction)
|
Left to Right
|
5
|
<<
>>
<<<
|
Left to Right
|
6
|
<
<=
>
>=
instanceof
|
Left to Right
|
7
|
==
!=
|
Left to Right
|
8
|
&
|
Left to Right
|
9
|
^
|
Left to Right
|
10
|
|
|
Left to Right
|
11
|
&&
|
Left to Right
|