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

7/7

Page

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

What is the String in C# meant for?

Select an option to see the answer and solution.

Which of these operators can be used to concatenate two or more String objects?

Select an option to see the answer and solution.

Which of these is used as a default specifier for a member of the class if no access specifier is used for it?

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

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 s1 = "Hello I Love Csharp ";
    Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p'));
    Console.ReadLine();
}

Select an option to see the answer and solution.

The method in which large or variable number of arguments are handled is known as . . . . . . . .

Select an option to see the answer and solution.

Which among the following is the correct way to find out the index of second 's' in the string "She sold her beauty in one night to someone else"?

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

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
static void main(String args[])
{
    char chars[] = {'x', 'y', 'z'};
    String s = new String(chars);
    Console.WriteLine(s);
}

Select an option to see the answer and solution.

Choose the statements which are false in nature?

Select an option to see the answer and solution.

Which of these access specifiers must be used for main() method?

Select an option to see the answer and solution.

What will be the output of the following C# code?
class sum   
{
    public int x;
    public int y;
    public  int add (int a,  int b)
    {
        x = a + b;
        y = x + b;
        return 0;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        sum obj1 = new sum();
        sum obj2 = new sum();   
        int a = 2;
        obj1.add(a,  a + 1);
        obj2.add(5,  a);
        Console.WriteLine(obj1.x + "  " + obj2.y);     
        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 c = "  Hello Computer ";
    String a = c.Trim();
    Console.WriteLine("\"" + s + "\"");
}

Select an option to see the answer and solution.

Which of these methods of the class String is used to obtain length of String object?

Select an option to see the answer and solution.