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

3/7

Page

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

What is the correct way to declare and initialize a jagged array with 2 rows in C#?

Select an option to see the answer and solution.

What is the correct syntax to access the second character of a string named text in C#?

Select an option to see the answer and solution.

What is the result of the expression Array.IndexOf(numbers, 5) where numbers = {1, 2, 3, 4, 5} in C#?

Select an option to see the answer and solution.

In C#, which method is used to split a string into substrings based on a specified delimiter?

Select an option to see the answer and solution.

What is the correct way to declare and initialize a multidimensional array with 3 rows and 4 columns in C#?

Select an option to see the answer and solution.

Which of these methods of class String is used to extract all the characters from a String object?

Select an option to see the answer and solution.

What will be the output of the following C# code?
class math
{
    public int a,b;
    public math(int i,  int j)
    {
        a = i;
        b = j;
    }
    public  void sum(math m)
    {
        m.a *= 2;
        m.b += 2;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        math t = new math(20,  10);
        t.sum(t);
        Console.WriteLine(t.a + "  " + t.b);   
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Which of these base classes are accessible to the derived class members?

Select an option to see the answer and solution.

What is the process by which we can control parts of a program that can access the members of a class?

Select an option to see the answer and solution.

Which of these methods of class are used to remove the leading and backward whitespaces?

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 a = "Ilove";
    String b = "CSHARP";
    b = string.Concat(a, '  ', b);
    Console.WriteLine(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)
{
    String obj = "hello";
    String obj1 = "world";   
    String obj2 = obj;
    string s = obj+" "+obj1;
    Console.WriteLine(s.IndexOf('r'));
    Console.ReadLine();
}

Select an option to see the answer and solution.

What does the term 'immutable' means in term of string objects?

Select an option to see the answer and solution.

Accessibility modifier defined in a class are?

Select an option to see the answer and solution.

Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

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 i;
    int res = fun (out i);
    console.writeline(res);
    console.readline();
}
static int fun(out int i)
{
    int s = 1;
    i = 7;
    for (int j = 1; j <= i; j++ )
    s = s * j;
    return s;
}

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 obj = "hello";
    String obj1 = "world";   
    String obj2 = obj;
    string s = obj + "  " + obj1;
    Console.WriteLine(s.Substring(6 ,5));
    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 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();
    }
}

Select an option to see the answer and solution.

The modifiers used to define an array of parameters or list of arguments is . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    object[] a = {" 1 ", 4.0f, " harsh "};
    fun(a);
    Console.ReadLine();
}
static void fun(params object[] b)
{
    for (int i = 0; i < b.Length - 1; i++)
        Console.WriteLine(b[i] + " ");
}

Select an option to see the answer and solution.