1.

How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a? int[][]a = new int[2][]; a[0] = new int[4]{6, 1 ,4, 3}; a[1] = new int[3]{9, 2, 7}; foreach (int[ ] i in a) { /* Add loop here */ Console.Write(j + " "); Console.WriteLine(); }

A. <i class="csharp-code">foreach (int j = 1; j &lt; a(0).GetUpperBound; j++)</i>
B. <i class="csharp-code">foreach (int j = 1; j &lt; a.GetUpperBound (0); j++)</i>
C. <i class="csharp-code">foreach (int j in a.Length)</i>
D. <i class="csharp-code">foreach (int j in i)</i>
E. <i class="csharp-code">foreach (int j in a.Length -1)</i>
Answer» E. <i class="csharp-code">foreach (int j in a.Length -1)</i>


Discussion

No Comment Found

Related MCQs