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

5/9

Page

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

What are strings in C#?

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 = 2.0;  
        double y = 3.0;
        double z = Math.Pow( x, y );
        Console.WriteLine(z);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What is multithreaded programming?

Select an option to see the answer and solution.

Which is the correct statement about the namespaces in C#.NET?

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.Ceiling(x);
        Console.WriteLine(y);
    }
}

Select an option to see the answer and solution.

Which method is used to abort thread prior to it's normal execution?

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class MyClass
{
    int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
    public IEnumerator GetEnumerator()
    {
        for (int i = 0; i < 20; i++)
        {
            if (a[i] % 2 == 0)
            yield return (int)(a[i]);
        }
    }
}
class Program
{
    static void Main(string[] args)
    {
        MyClass mc = new MyClass();
        foreach (int i in mc)
        Console.Write(i + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
#define DEBUG 
#define MYTEST
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication13
{
    class Program
    {   
        static void Main(string[] args)
        {
            #if (DEBUG && !MYTEST)
            Console.WriteLine("DEBUG is defined");
            #elif (!DEBUG && MYTEST)
            Console.WriteLine("MYTEST is defined");
            #elif (DEBUG && MYTEST)
            Console.WriteLine("DEBUG and MYTEST are defined");
            #else
            Console.WriteLine("DEBUG and MYTEST are not defined");
            #endif
            Console.ReadLine();
        }
    }
}

Select an option to see the answer and solution.

Which is the correct statement about an ArrayList collection that implements the IEnumerable interface?

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[] = {'a', 'b', 'c'};
    String s = new String(chars);
    Console.WriteLine(s);
}

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 World  ";
        String s = c.Trim();
        Console.WriteLine("""+s+""");
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Select the operators used for checking the equality in strings:

Select an option to see the answer and solution.

Which of the following functions return absolute value of a variable?

Select an option to see the answer and solution.

Select the defined preprocessor in C#.NET?

Select an option to see the answer and solution.

Choose the correct statement among the given statements?

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 s = "Hello World";
        int i = s.IndexOf('o');
        int j = s.LastIndexOf('l');
        Console.WriteLine(i + " " + j);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Which of the following job is done by the instruction ++*p for an integer pointer p?

Select an option to see the answer and solution.

What does the following code depicts?
i. System.Nullable count;
ii. bool? done;

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
public class A
{
    public int x;
    public int y;
    public void display() 
    {
        Console.WriteLine(x + " " + y);
    }
}
class Program
{
    static void Main(string[] args)
    {
        A obj1 = new A();
        A obj2 = new A();
        obj1.x = 1;
        obj1.y = 2;
        obj2 = obj1;
        obj1.display();
        obj2.display();
    }
}

Select an option to see the answer and solution.

Which feature enables to obtain information about the use and capabilities of types at runtime?

Select an option to see the answer and solution.