adplus-dvertising

Welcome to the Arrays and Strings MCQs Page

Dive deep into the fascinating world of Arrays and Strings with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Arrays and Strings, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Arrays and Strings, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Arrays and Strings. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Arrays and Strings. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Arrays and Strings MCQs | Page 1 of 16

Explore more Topics under C# programming

Q1.
Which of the following statements are correct about the C#.NET code snippet given below?

int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};

1. intMyArr represents rectangular array of 2 rows and 3 columns.
2. intMyArr.GetUpperBound(1) will yield 2.
3. intMyArr.Length will yield 24.
4. intMyArr represents 1-D array of 5 integers.
5. intMyArr.GetUpperBound(0) will yield 2.
Discuss
Answer: (a).1, 2
Q2.
Which of the following statements are correct about the C#.NET code snippet given below?

int[] a = {11, 3, 5, 9, 4};

1. The array elements are created on the stack.
2. Refernce a is created on the stack.
3. The array elements are created on the heap.
4. On declaring the array a new array class is created which is derived from System.Array Class.
5. Whether the array elements are stored in the stack or heap depends upon the size of the array.
Discuss
Answer: (b).2, 3, 4
Discuss
Answer: (d).The default value of numeric array elements is zero.
Q4.
If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?
Discuss
Answer: (d).int[] a = new int[5];
a = new int[10];
Q5.
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(); 
    }
Discuss
Answer: (d).foreach (int j in i)
Q6.
Which of the following is the correct output of the C#.NET code snippet given below?

    int[ , , ] a = new int[ 3, 2, 3 ]; 
    Console.WriteLine(a.Length);
Discuss
Answer: (c).18
Q7.
Which of the following statements are correct about arrays used in C#.NET?

1. Arrays can be rectangular or jagged.
2. Rectangular arrays have similar rows stored in adjacent memory locations.
3. Jagged arrays do not have an access to the methods of System.Array Class.
4. Rectangular arrays do not have an access to the methods of System.Array Class.
5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.
Discuss
Answer: (d).1, 2, 5
Q8.
Which of the following statements are correct about the C#.NET code snippet given below?

   int[][]intMyArr = new int[2][]; 
   intMyArr[0] = new int[4]{6, 1, 4, 3}; 
   intMyArr[1] = new int[3]{9, 2, 7};
Discuss
Answer: (c).intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array.
Q9.
Which of the following are the correct ways to define an array of 2 rows and 3 columns?

1.
int[ , ] a;
a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};

2.
int[ , ] a;
a = new int[2, 3]{};

3.
int[ , ] a = {{7, 1, 3}, {2, 9,6 }};

4.
int[ , ] a;
a = new int[1, 2];

5.
int[ , ] a;
a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};
Discuss
Answer: (b).1, 3
Discuss
Answer: (c).intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!