Select chapter



Basics (2.papers)
Data Types (2.papers)
enums (2.papers)
OOPS (4.papers)
Arrays (1.papers)
Structs (2.papers)
Properties (2.papers)
Strings (2.papers)
Interfaces (1.papers)
Constructors (2.papers)
Ref-Out-Keywords (1.papers)
Collections (2.papers)
Generics (1.papers)
Hide

Sponsored Links


  

c# arrays interview questions and answers

1
What is an Array ?
  1. An Array is a collection used for storing unrelated data.
  2. An Array is a collection which is used for storing logically related multiple values under a single variable name.
  3. An Array is used only for storing collection of numbers or strings.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
2
Which of the following is not true about an Array ?
  1. Array is used for storing homogeneous collection of data.
  2. Array declaration can reduce number variables declaration.
  3. Array is a fixed size element or entity in csharp.
  4. Multi dimensional arrays are not supported in csharp.
Show Answer
Share Facebook gmail Twitter
3
Which of the following way is correct to increase size of an existing array(length=2) to 7?
  1. int[] a = new int[2]; 
    int[] a = new int[7];
  2. int[] a = new int[2]; 
     a = new int[7];
  3. It is not possible to change the size of an existing array.
  4. int[] a = new int[2]; a.SetUpperBound=7;
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
Which of the below statements are correct about following code ?
int[] i = new int[0] { };
  1. Code will give Compilation error.
  2. Code will give runtime error.
  3. An array will be created without any cells. 
  4. None of the above
Show Answer
Share Facebook gmail Twitter
7
How to sort elements of an array in Ascending order?
  1. By calling Array.Ascend(array);
  2. By calling Array.SortAscend(array);
  3. By calling Array.AscendSort(array);
  4. By calling Array.Sort(array);
Show Answer
Share Facebook gmail Twitter
8
How to sort the elements of an array in Descending order?
  1. By calling Reverse() method present in Array class.
  2. By calling Sort() and then Reverse() methods present in Array class.
  3. By calling ReverseSort() present in Array class.
  4. By calling Descend() present in Array class.
Show Answer
Share Facebook gmail Twitter
9
Which of the following statement is true about the given Array?   
int[] obj=new int[3]{ 1, 2, 3 };
  1. obj is a reference to an object of System.Array Class.
  2. obj is a reference to an object of a class that the compiler derives fromSystem.Array Class.
  3. obj is a reference to an object created on the stack
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
11
How to declare a 2-dimensional array in c# ?
  1. int[][] a=new int[2][2];
  2. int[,] a={{1,2},{2,4}};
  3. int[,] a=new int[3,2,2] { {{1,2},{0,9}},{{9,7},{2,4}},{{-6,-3},{0,-9}} };
  4. int[,] a=new int[2,2] {{1,2},{2,4}};
Show Answer
Share Facebook gmail Twitter
12
Which of the following statement is wrong about Jagged arrays that are used in C#.NET
  1. A jagged array is an array of arrays.
  2. Length of each array should be same in the jagged array.
  3. Base class of jagged array is System.Array.
  4. Jagged arrays are array of arrays, there is no restriction that requires that the arrays be one-dimensional.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
14
How to declare a 3-Dimensional array in c# ?
  1. int[][][] aa;
  2. int[3] aa;
  3. System.Array[3] aa;
  4. int[,,] aa;
Show Answer
Share Facebook gmail Twitter
15
What is the difference between the System.Array.Clone and System.Array.CopyTo?
  1. CopyTo() does a deep copy.
  2. The CopyTo() method copies the elements into another existing array.
  3. The Clone() method returns a new array(a shallow copy) object containing all the elements in the original array.
  4. 2 and 3
Show Answer
Share Facebook gmail Twitter
16
Which is the best way to read data present in the given array ?
int[] numbers = new int[4] { 10, 20, 40, 30 };
  1. foreach (int j in numbers)
            {
                Console.WriteLine(j);
            }
  2. for (int i = 0; i < numbers.Length; i++)
            {
                Console.WriteLine(numbers[i]);
            }
  3. int i=0;
            while (i < numbers.Length)
            {
                Response.Write(numbers[i]);
                i++;
            }
  4. All of the above
Show Answer
Share Facebook gmail Twitter
17
Which of the following is the main advantage of an Array?
  1. By using an array we can store logically related multiple values using a single variable.
  2. By using arrays we can store objects information.
  3. We can use for loop and foreach loop for iterating arrays data.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
18
Which of the below given syntax is wrong way of declaring an array in C# ?
  1. int[] k=new int[];
  2. int[] j = new int[] { 20, 50, 20 };
  3. int[] i = new int[4];
  4. None of the above
Show Answer
Share Facebook gmail Twitter
19
Which of the below given syntax is the wrong way of returning a boolean result when an array contains given number ?
  1. public bool IsExists(int[] nums, int i)
            {
                for (int j = 0; j < nums.Length; j++)
                {
                    if (nums[j] == i)
                        return true;
                }
                return false;
            }
  2. public bool IsExists(int[] nums, int i)
            {
                foreach (var item in nums)
                {
                    if (item == i)
                        return true;
                }
                return false;
            }
  3. public bool IsExists(int[] nums, int i)
            {
                bool b = false;
                foreach (var item in nums)
                {
                    if (item == i)
                        b = true;
                }
                return b;
            }
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Read more papers :