General Questions

Question 11 :

Which of the following is the correct output of the C#.NET code snippet given below?

int[][] a = new int[2][];
a[0] = new int[4]{6, 1, 4, 3};
a[1] = new int[3]{9, 2, 7}; 
Console.WriteLine(a[1].GetUpperBound(0));


A). 3
B). 4
C). 7
D). 9
E). 2
Answer : Option E

Question 12 :

Which of the following is the correct way to obtain the number of elements present in the array given below?

int[] intMyArr = {25, 30, 45, 15, 60};
intMyArr.GetMax;
intMyArr.Highest(0);
intMyArr.GetUpperBound(0);
intMyArr.Length;
intMyArr.GetMaxElements(0);


A). 1, 2
B). 3, 4
C). 3, 5
D). 1, 5
E). 4, 5
Answer : Option B

Explanation :

using System;
public class Test
{ 
   public static void Main()
   { 
        int[] intMyArr = { 25, 30, 45, 15, 60, 78, 99 };
        Console.WriteLine(intMyArr.Length);
        Console.WriteLine(intMyArr.GetUpperBound(0)+1);
   } 
}
/* 
Output : 
7 
7 
*/


Question 13 :

What will be the output of the C#.NET code snippet given below?

namespace IndiaparinamConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i, j;
            int[ , ] arr = new int[ 2, 2 ];
            for(i = 0; i < 2; ++i)
            {
                for(j = 0; j < 2; ++j)
                {
                    arr[i, j] = i * 17 + i * 17;
                    Console.Write(arr[ i, j ] + " ");
                }
            }
        }
    }
}


A). 0 0 34 34
B). 0 0 17 17
C). 0 0 0 0
D). 17 17 0 0
E). 34 34 0 0
Answer : Option A