Vidyalelo
C# Programming · all questions

Miscellaneous in C Sharp
practice.

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

170

Questions

3/9

Page

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

Accessibility modifiers defined in a class are?

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        int[] nums = {3 ,1 ,2 ,5 ,4};
        var ltAvg = from n in nums
                    let x = nums.Average()
                    where n < x
                    select n;
        Console.WriteLine("The average is " + nums.Average());
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What is mutex?

Select an option to see the answer and solution.

Which of these constructors is used to create an empty String object?

Select an option to see the answer and solution.

Which among the following is a .NET namespace?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the following C# code snippet specify?
class MyClass
{
    char chrs = 'A' ;
    public IEnumerator GetEnumerator()
    {
        for (int i = 20; i >=0; --i)
        if (i == 10) yield break;
        yield return (char)((chrs + i));
    }
}
class Program
{
    static void Main(string[] args)
    {
        MyClass mc = new MyClass();
        foreach (char ch in mc)
        Console.Write(ch + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        String s1 = "one";
        String s2 = string.Concat(s1 + " " + "two");
        Console.WriteLine(s2);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class UnsafeCode
{
    unsafe static void Main()
    {
        int* ptrs = stackalloc int[3];
        ptrs[0] = 1;
        ptrs[1] = 2;
        ptrs[2] = 3;
        for (int i = 2; i >= 0; --i)
        {
            ptrs[i] = ptrs[i]* 3;
            ptrs[i] = ptrs[i] + 4;
            Console.WriteLine(ptrs[i]);
        }
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Choose the base class for string() method.

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.

What does the yield return statement specify in the following C# code snippet?
public System.Collections.IEnumerator GetEnumerator()
{
    foreach (char ch in chrs)
    yield return ch;
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        int y = (int)Math.Max(4,2);
        int z = (int)Math.Pow(y, 2);
        Console.WriteLine(z);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

In which of the following collections is the I/O based on a key?

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class UnsafeCode
{
    unsafe static void Main()
    {
        int m = 10;
        int *mptr = &m;
        int **ptr = &mptr;
        int n = 20;
        int *nptr = &n;
        int **prt = &nptr;
        m = **prt + *nptr;
        n = *mptr* **prt;
        Console.WriteLine(n + " " + m);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        double x = 3.14;  
        int y = (int) Math.Abs(x);
        Console.WriteLine(y);
    }
}

Select an option to see the answer and solution.

Which among the following is not a preprocessor directive?

Select an option to see the answer and solution.

Which among the following is the correct way to find out the number of elements currently present in an ArrayListCollection called arr?

Select an option to see the answer and solution.

Which of these method returns a smallest whole number greater than or equal to variable X?

Select an option to see the answer and solution.

Which statement is correct in the following C#.NET code snippet?
Stack st = new Stack();
st.Push("Csharp");
st.Push(7.3);
st.Push(8);
st.Push('b');
st.Push(true);

Select an option to see the answer and solution.