KnowledgeBoat Logo
|

Computer Applications

What will be the result stored in x after evaluating the following expression?

int x = 4;
x += (x++) + (++x) + x;

Java Operators

ICSE 2012

102 Likes

Answer

    x += (x++) + (++x) + x
⇒ x = x + ((x++) + (++x) + x)
⇒ x = 4 + (4 + 6 + 6)
⇒ x = 4 + 16
⇒ x = 20

Answered By

62 Likes


Related Questions