Advertisements
Advertisements
Question
Evaluate the following expression as per Java priority & associativity.
6 * 2 / 4
Evaluate
Advertisements
Solution
Priority (Precedence): Both multiplication (*) and division (/) have the same precedence level in Java.
Associativity: Since their precedence is equal, Java evaluates them from left to right.
- First, evaluate the left-most operation: 6 * 2 = 12
- Next, evaluate the remaining operation: 12 / 4 = 3
shaalaa.com
Is there an error in this question or solution?
