To answer this question, let's go through each line of code and track the values of the variables:
int i,j,k,l=0;
: This line declares four variables i
, j
, k
, and l
. l
is initialized to 0.
k = l++;
: The value of l
is assigned to k
first, and then l
is incremented by 1. So, k
becomes 0, and l
becomes 1.
j = ++k;
: k
is incremented by 1 first, and then the value of k
is assigned to j
. So, k
becomes 1, and j
becomes 1.
i = j++;
: The value of j
is assigned to i
first, and then j
is incremented by 1. So, i
becomes 1, and j
becomes 2.
System.out.println(i);
: The value of i
is printed, which is 1.
Therefore, the correct answer is B) 1.