Computer Applications

Evaluate the given expression when the value of a=2 and b=3

b*=a++ - ++b + ++a;
System.out.println("a= "+a); 
System.out.println("b= "+b);

Java Operators

ICSE Sp 2025

12 Likes

Answer

a = 4, b = 6

Explanation:

The given expression is evaluated as follows:

b*=a++ - ++b + ++a
b = b * (a++ - ++b + ++a) [a=2, b=3]
b = 3 * (2 - 4 + 4) [a=4, b=4]
b = 3 * 2
b = 6

Answered By

10 Likes


Related Questions