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 2 of 16

Discuss
Answer: (b).intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.
Q12.
Which of the following is the correct way to define and initialise an array of 4 integers?

1.
int[] a = {25, 30, 40, 5};

2.
int[] a;
a = new int[3];
a[0] = 25;
a[1] = 30;
a[2] = 40;
a[3] = 5;

3.
int[] a;
a = new int{25, 30, 40, 5};

4.
int[] a;
a = new int[4]{25, 30, 40, 5};

5.
int[] a;
a = new int[4];
a[0] = 25;
a[1] = 30;
a[2] = 40;
a[3] = 5;
Discuss
Answer: (c).1, 4, 5
Q13.
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.

2

Discuss
Answer: (d).2
Q14.
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};

1. intMyArr.GetMax;
2. intMyArr.Highest(0);
3. intMyArr.GetUpperBound(0);
4. intMyArr.Length;
5. intMyArr.GetMaxElements(0);
Discuss
Answer: (b).3, 4
Q15.
What will be the output of the C#.NET code snippet given below?

namespace CompScibitsConsoleApplication
{
    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 ] + " ");
                }
            }
        }
    }
}
Discuss
Answer: (a).0 0 34 34
Q16.
Which of the following statements are true about the C#.NET code snippet given below?

1. String objects cannot be created without using new.
2. Only one object will get created.
3. s1 and s2 both will refer to the same object.
4. Two objects will get created, one pointed to by s1 and another pointed to by s2.
5. s1 and s2 are references to the same object.

String s1, s2; 
s1 = "Hi"; 
s2 = "Hi";
Discuss
Answer: (b).2, 3, 5
Q17.
Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "ALL MEN ARE CREATED EQUAL";
String s2;
s2 = s1.Substring(12, 3); 
Console.WriteLine(s2);
Discuss
Answer: (b).CRE
Discuss
Answer: (c).String s1 = "String";
String s2;
s2 = String.Copy(s1);
Q19.
The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.
Discuss
Answer: (a).True
Q20.
Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "Nagpur";
String s2;
s2 = s1.Insert(6, "Mumbai"); 
Console.WriteLine(s2);
Discuss
Answer: (d).NagpurMumbai
Page 2 of 16

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!