Value of x

This is interview question,

public void A()
{
int x;
x = 8;
x *= 4 + 8 / 2;
}
Given the above code, what is the value of "x"?

options:- A) 3
B) 2
C)4
D) None

Questions by nithya R   answers by nithya R

Showing Answers 1 - 21 of 21 Answers

x *= 4 + 8/2  is equivalent to x = x * (4 + 8/2)

This equates to x = x * (4 + 4) /* the division operation is carried out prior to the addition operation */

Which is nothing but x = 8 * 8 => 64

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.