C# Arrays and Strings Mcqs

Our collections of Multiple choice questions and answers focuses on study of C# Arrays and Strings. These topics are chosen from a collection of most authoritative and best reference books on C# Arrays and Strings. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our mcqs to assimilate C# Arrays and Strings Topic comprehensively.

  1. Home
  2. »
  3. Languages
  4. »
  5. Programming Languages Mcqs
  6. »
  7. C# Programming Mcqs
  8. »
  9. Arrays and Strings mcqs
  10. »
  11. Page 3

31.
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();
    }
}

0,0,0 4,4,4 8,8,8

4,4,4 8,8,8 12,12,12

8,8,8 12,12,12 16,16,16

0,0,0 1,1,1, 2,2,2

32.
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();
 }

M L

U L

L M

A B

33.
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();
}

Foreach (int j = 1;(j(<)(a(0).GetUpperBound)), (j++));

Foreach (int j = 1;(j(<)(a.GetUpperBound(0))), (j++));

Foreach (int j in a.Length);

Foreach (int j in i);

34.
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();
}

98

89

88

84

35.
Which statement is correct about following c#.NET code ?

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

‘a’ is a reference to the array created on stack

‘a’ is a reference to an object created on stack

‘a’ is a reference to an object of a class that compiler drives from ‘System.Array’ class

None of the mentioned

36.
What is the advantage of using 2D jagged array over 2D rectangular array?

Easy initialization of elements

Allows unlimited elements as well as rows which had ‘0’ or are empty in nature

All of the mentioned

None of the mentioned

37.
Which statement is correct about following set of code ?

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

A’ represents 1-D array of 5 integers

A.GetUpperBound(0) gives 9

A’ represents rectangular array of 2 columns and 3 arrays

A.GetUpperBound(0) gives 2

38.
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);
    }
}

Compile time error

Run time error

Code runs successfully but prints nothing

Code runs successfully and prints given on console

39.
Which is the correct way of defining and initializing an array of 3 integers?

Int[] a={78, 54};

Int[] a; a = new int[3]; a[1] = 78; a[2] = 9; a[3] = 54;

Int[] a; a = new int{78, 9, 54};

Int[] a; a = new int[3] {78, 9, 54};

40.
Choose selective differences between an array in c# and array in other programming languages.

Declaring array in C# the square bracket([]) comes after the type but not after identifier

It is necessary to declare size of an array with its type

No difference between declaration of array in c# as well as as in other programming languages

All of the mentioned

43.
What is output for the following set of code:
static void Main(string[] args)
 {
     string s1 = " Cshr ";
     string s2 = s1.Insert(3 , " a ");
     string s3 = s2.Insert(5 , " p ");
     for (int i = 0;i < s3.Length; i++)
     Console.WriteLine(s3[i]);
     Console.ReadLine();
 }

Cshar

CsharP

Csharp

Cshrap

44.
Which of the following statement is correct about a string in C#.NET?

The System.Array class is used to represent a string

A string has a zero-based index

A number cannot be represented in the form of a string

A string is mutable because it can be modified once it has been created

45.
What is output for the following set of code?
static void Main(string[] args)
 {
     string s1 = "Hello";
     string s2 = "hello";
     if (s1 == s2)
     Console.WriteLine("Equal");
     else
     Console.WriteLine("Unequal");
     if (s1.Equals (s2))
     Console.WriteLine("Equal");
     else
     Console.WriteLine("Unequal");
     Console.ReadLine();
 }

Equal - Unequal

Unequal - Equal

Equal - Equal

Unequal - Unequal

error: You are not allowed to do so.....
0Shares
0
Scroll to Top