Vidyalelo
C# Programming · all questions

Arrays and Strings in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

134

Questions

6/7

Page

Pick an option on a question to see the right answer and solution.

Keyword used to define call by reference parameter in C# .NET?

Select an option to see the answer and solution.

How is a string typically processed?

Select an option to see the answer and solution.

What will be the output of the following C# code?
class Program
{
    static void Main(string[] args)
    { 
        String c = "i love Csharp";
        bool a;
        a = c.StartsWith("I");
        Console.WriteLine(a);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
class Program
{
    static void Main(string[] args)
    {
        int i = 5;
        int j;
        method1(ref i);
        method2(out j);
        Console.writeline(i + "  " + j);
    }
    static void method1(ref int x)
    { 
        x = x + x;
    }
    static void method2(out int x)
    {
        x = 6;
        x = x * x;
    }
}

Select an option to see the answer and solution.

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

Options are not available for this question.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of the following statements are correct?

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void main(string[] args)
{
    int n = 1;
    method(n);
    console.Writeline(n);
    method1(ref n);
    console.Writeline(n);
}
static void method(int num)
{
    num += 20;
    console.writeline(num);
}
static void method1(ref int num)
{
    num += 20;
    console.writeline(num);
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    String c = "Hello";
    String a = c + "Bye";
    Console.WriteLine(a);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    char A = 'K';
    char B = Convert.ToChar(76);
    A++;
    B++;
    Console.WriteLine(A+ "  " +B);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int [] a = {1, 2, 3, 4, 5};
    fun(a);
    Console.ReadLine();
}
static void fun(params int[] b )
{
    int[] k = { 3, 4, 7, 8,'\0' };
    for (int i = 0; i < b.Length; i++)
    {
        b[i] = b[i] + k[i] ;
        Console.WriteLine( b[i] + " ");
    }
}

Select an option to see the answer and solution.

Which of the following string() method are used to compare two strings with each other?

Select an option to see the answer and solution.

Which statement is correct about following c#.NET code?
int[] a= {11, 3, 5, 9, 6};

Select an option to see the answer and solution.

What will be the output of the following C# code?
 static void Main(string[] args)
 {
     int[] a = { 2, 21, 34, 46, 85, 88, 90};
     fun(a);
     Console.WriteLine(a + " ");
     Console.ReadLine();
 }
 static void fun(params int [] b )
 {
     int [] c = { 1, 2, 3, 4, 5, 6, 7};
     int i ;
     for (i = 0 ;i < b.Length ;i++)
     if (b[i] % 2 == 0)
     {
         c[i] = b[i];
     }
     Console.WriteLine("even numbers are:");
     for (i = 0 ;i <= b.Length ;i++)
     {
         Console.WriteLine(c[i]);
     }
 }

Select an option to see the answer and solution.

How to print \ on the screen?

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int a = 5;
    int b = 0, c = 0;
    method (a,  ref b, ref c);
    Console.WriteLine(b + "  " + c);
    Console.ReadLine();
}
static int method(int x, int p, ref int k)
{
    p = x + x * x;
    k = x * x + p;
    return 0;
}

Select an option to see the answer and solution.

Which statement is/are correct?

Select an option to see the answer and solution.

Which of these methods of class String is used to compare two String objects for their equality?

Select an option to see the answer and solution.

Which of these is used to access members of class before the object of that class is created?

Select an option to see the answer and solution.

What is the value returned by function compareTo() if the invoking string is less than the string compared?

Select an option to see the answer and solution.