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

4/7

Page

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

Select the correct match of parameter declaration.
static Void main(string[] args)
{
    int a = 5;
    int b = 6;
    float c = 7.2f;
    math (ref a, ref b, ref c);
    Console.WriteLine(a + "  " + b + "  " + c);
}
static int math(/*add parameter declaration */)
{
    a += b;
    b *= (int)c;
    c += a * b;
    return 0;
}

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[] x = { 80, 82, 65, 72, 83, 67 };
    fun(x);
    Console.ReadLine();
}
static void fun(params int [] b )
{
    int i;
    for (i = 5; i >=0 ; i--)
    {
        Console.WriteLine(Convert.ToChar(b[i]));
    }
}

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)
{
    string c = "hello";
    string  c1 = c.Remove(1);
    Console.WriteLine(c1);
    Console.ReadLine();
}

Select an option to see the answer and solution.

Which method does following C# code explains?
static void Main(string[] args)
{
    int a = 10, b = 20;
    method(ref a,  ref b);
    console.writeline(a + "  " + b);
}
static void swap(ref int i,  ref int j)
{  
    int t;
    t = i;
    i = j;
    j = t;
}

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 )
 {
     for (int i = 0; i < b.Length; i++)
     {
         b[i] = b[i] * 5 ;
         Console.WriteLine(b[i] + "");
     }
 }

Select an option to see the answer and solution.

Which of these data type values is returned by equals() method of String class?

Select an option to see the answer and solution.

Which statement is correct about following C# code?
int[, ]a={{5, 4, 3},{9, 2, 6}};

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 s1 = "I love You";
        String s2 = s1;
        Console.WriteLine((s1 == s2) + " " + s1.Equals(s2));
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Correct way to convert a string to uppercase using string class method()?

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 s = " i love you";
    Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));
    Console.ReadLine();
}

Select an option to see the answer and solution.

The Method use to remove white space from a string?

Select an option to see the answer and solution.

Correct way to find if contents of two strings are equal?

Select an option to see the answer and solution.

Which of these methods can be used to convert all characters in a String into a character array?

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 ;
    a = c.Replace('l', 'w');
    Console.WriteLine(a);
    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)
{
    String c = "Hello i love you";
    String a ;
    a = c.Substring(12, 3);
    Console.WriteLine(a);
    Console.ReadLine();
}

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)
{
    String obj = "hello";
    String obj1 = "world";   
    String obj2 = obj;
    Console.WriteLine(obj + "  " + obj1);
    string s = obj + "  " + obj1;
    Console.WriteLine(s.Length);
    Console.ReadLine();
}

Select an option to see the answer and solution.

Which of these methods returns the string such that some characters which are specified to be removed from the end of strings are removed from string by mentioning the number of characters to be removed?

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;
    Console.WriteLine (obj.Equals(obj2) + "  " + obj2.CompareTo(obj) );
    Console.ReadLine();
}

Select an option to see the answer and solution.

To perform comparison operation on strings supported operations are . . . . . . . .

Select an option to see the answer and solution.