English

Evaluate the following expression as per Java priority and associativity. 6 * 2 / 4

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?
Chapter 1: Revision of Class 9 Syllabus - Exercises [Page 45]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 1 Revision of Class 9 Syllabus
Exercises | Q 4. (i) | Page 45
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×