OOPS
August 29, 2024OOPS
August 29, 2024OOPS
|
Question 95
|
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++;
int x,y=10; z=12;
x=y++ + z++;
|
x=22, y=10, z=12
|
|
|
x=24, y=10, z=12
|
|
|
x=24, y=11, z=13
|
|
|
x=22, y=11, z=13
|
Question 95 Explanation:
x = y++ + z++;
Post increment operator first perform the action and then it increment the value.
First perform addition of ‘y’ and ‘z’ and later increment ‘y’ and ‘z’ values
So, the value of x = 10 + 12 = 22, y = 11 and z = 13.
Post increment operator first perform the action and then it increment the value.
First perform addition of ‘y’ and ‘z’ and later increment ‘y’ and ‘z’ values
So, the value of x = 10 + 12 = 22, y = 11 and z = 13.
Correct Answer: D
Question 95 Explanation:
x = y++ + z++;
Post increment operator first perform the action and then it increment the value.
First perform addition of ‘y’ and ‘z’ and later increment ‘y’ and ‘z’ values
So, the value of x = 10 + 12 = 22, y = 11 and z = 13.
Post increment operator first perform the action and then it increment the value.
First perform addition of ‘y’ and ‘z’ and later increment ‘y’ and ‘z’ values
So, the value of x = 10 + 12 = 22, y = 11 and z = 13.
