1)

Select the output for the given set of programming code:

static void Main(string[] args)
{
int i ;
for (i = 0; i <=2; i++)
{
int j = 0;
j += i;
Console. WriteLine(j);
}
Console. WriteLine( i * j);
Console. ReadLine();
}


A) Compile time error

B) 0, 2, 4

C) 4, 2, 0

D) 2, 0, 4

Answer:

Option A

Explanation:

The scope of the variabe 'j' is inside the for loop. It cannot be used outside for loop block.