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

ICSE Class 10 Computer Applications PYQ · 2025 Specimen · Section A

2(ii)1 Mark · 2025 · Section A · 2025 Specimen

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);
Show SolutionHide Solution↓

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

← Previous questionNext question →

Browse the free Computer Applications sample bank