1
visibility

What will be the output of the following code?

int k = 5, j = 9;
k += k++ – ++j + k;
System.out.println(“k= ” +k);
System.out.println(“j= ” +j);

  • k = 5
    j = 9

  • k = 6
    j = 10

  • k = 5
    j = 10

  • k = 7
    j = 9

k += k++ – ++j + k
k = k + k++ – ++j + k
k = 5 + 5 – 10 + 6
k = 6
j = 10 as it has been incremented in the ++j operation.