KnowledgeBoat Logo

Computer Applications

Predict the output:

int a=6,b=5;
a += a++ % b++ *a + b++* --b;

Java

Java Operators

93 Likes

Answer

a = 49

Working

   a += a++ % b++ *a + b++* --b  
=> a = a + (a++ % b++ *a + b++* --b)
=> a = 6 + (6 % 5 * 7 + 6 * 6)  
// % and * will be applied first due to higher precedence
=> a = 6 + (7 + 36)
=> a = 49

Answered By

47 Likes


Related Questions