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

Explore more Topics under C# programming

Q31.
Which of the following statements are correct?

1. String is a value type.
2. String literals can contain any character literal including escape sequences.
3. The equality operators are defined to compare the values of string objects as well as references.
4. Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeException.
5. The contents of a string object can be changed after the object is created.
Discuss
Answer: (c).2, 4
Discuss
Answer: (c).String str = "She sells sea shells on the sea-shore";
int i, j;
i = str.IndexOf("s");
j = str.IndexOf("s", i + 1);
Q33.
What is the output of the following set of code ?
static void Main(string[] args)
{
    int i, j;
    int[, ] arr = new int[ 3, 3];
    for (i = 0; i < 3; ++i)
    {
        for (j = 0; j < 3; ++j)
        {
            arr[i, j] = i * 2 + i * 2;
            Console.WriteLine(arr[i, j]);
        }
        Console.ReadLine();
    }
}
Discuss
Answer: (a).0,0,0 4,4,4 8,8,8
Q34.
What is the output for the following set of code?
static void Main(string[] args)
 {
     char A = 'K';
     char B = Convert.ToChar(76);
     A++;
     B++;
     Console.WriteLine(A+ "  " +B);
     Console.ReadLine();
 }
Discuss
Answer: (c).L M
Q35.
Complete the following set of code with β€œforeach condition”:
int[][]a = new int[2][];
a[0] = new int[3]{3, 4, 2};
a[1] = new int[2]{8, 5};
foreach( int[]i in a)
{
/* add for loop */
console.write( j+ " ");
console.writeline();
}
Discuss
Answer: (d).foreach (int j in i);
Q36.
What is the output for the following set of code ?
static void Main(string[] args)
{
    double a = 345.09;
    byte c = (byte) a;
    Console.WriteLine(c);
    Console.ReadLine();
}
Discuss
Answer: (b).89
Discuss
Answer: (c).β€˜a’ is a reference to an object of a class that compiler drives from β€˜System.Array’ class
Discuss
Answer: (b).Allows unlimited elements as well as rows which had β€˜0’ or are empty in nature
Discuss
Answer: (c).a’ represents rectangular array of 2 columns and 3 arrays
Q40.
What is output of the following set of code?
static void Main(string[] args)
{
    Program p = new Program();
    p.display(2, 3, 8);
    int []a = { 2, 56, 78, 66 };
    Console.WriteLine("example of array");
    Console.WriteLine("elements added are");
    p.display(a);
    Console.ReadLine();
}
public void display(params int[] b)
{
    foreach (int i in b)
    {
        Console.WriteLine("ARRAY IS HAVING:{0}", i);
    }
}
Discuss
Answer: (d).Code runs successfully and prints given on console

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!