English

Evaluate the following expression as per Java priority and associativity. 52 * 7 % 7

Advertisements
Advertisements

Question

Evaluate the following expression as per Java priority & associativity.

52 * 7 % 7

Evaluate
Advertisements

Solution

Priority (Precedence): Both multiplication (*) and modulo have the same precedence level in Java.

Associativity: Because their precedence is equal, Java evaluates them from left to right. 

  • 52 * 7: Evaluates first, giving 364.
  • 364 % 7: Divides 364 by 7. Since 364 is exactly divisible by 7 7 × 52 = 364, the remainder is 0.
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. (vi) | Page 45
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×