In Java, after executing the following code what are the values of x, y and z?

int x,y=10; z=12;

x=y++ + z++;

Answer is [D] x=22, y=11, z=13

Can you explain how x=22? Because increment operators has higher priority then '+'. operator. So x should be 24 here.

ans is (d)

x = y++ + z++;

As in post increment operator, first the value is assigned and then it is incremented, this statement can be re-written as:

x = y + z; y = y++; z = z++;

So, the value of x = 10 + 12 = 22, y = 10 + 1 = 11 and z = 12 + 1 = 13.

Option (D) is correct.