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

6/9

Page

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

The property signifies "Obtains a Module object that represents the module (an executable file) in which the reflected type resides". Choose the property which specifies the following statement?

Select an option to see the answer and solution.

Choose the symbol which begins a preprocessor directive in C#.NET?

Select an option to see the answer and solution.

What will be the declaration of the variable ptr as the pointer to array of 6 floats?

Select an option to see the answer and solution.

What is an iterator?

Select an option to see the answer and solution.

Which of these methods return a largest whole number less than or equal to variable X?

Select an option to see the answer and solution.

What does the following C# method specify?
Type[] GetGenericArguments()

Select an option to see the answer and solution.

What will be the output of the following C# code segment?
class UnsafeCode
{
    unsafe static void Main()
    {
         int n = 10;
         void* p = &n;
         Console.WriteLine(*p);
         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* p;
            p = (int*)(65535);
            Console.WriteLine((uint)p);
            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.Floor(x);
        Console.WriteLine(y);
    }
}

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[] nums = new int[10];
         Console.WriteLine("Index pointer like array.");
         fixed (int* p = nums)
         {
             for (int i = 0 ;i <10 ;i++)
             p[i] = i;
             for (int i = 10 ;i >0 ;i--)
             Console.WriteLine("p[{0}]: {1} ", i, p[i]);
             Console.ReadLine();
         }
     }
}

Select an option to see the answer and solution.

Which keyword is used for using the synchronization features defined by the Monitor class?

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[] nums = new int[10];
        fixed (int* p = &nums[0], p2 = nums)
        {
            if (p == p2)
            Console.WriteLine("p and p2 point to same address.");
            Console.ReadLine();
        }
    }
}

Select an option to see the answer and solution.

Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?
Stack st = new Stack();
st.Push(10);
st.Push(20);
st.Push(-5);
st.Push(30);
st.Push(6);

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class UnsafeCode
{
    static void Main()
    {
        int count = 100;
        int? result = null;
        int incr = 10;
        result = count + incr;
        if (result.HasValue)
            Console.WriteLine("result has this value: " + result.Value);
        else
            Console.WriteLine("result has no value");
        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)
    {
        int[] nums = { 1 };
        var posNums = from n in nums
                      select Math.Pow(4 ,3);
        Console.Write("The values in nums: ");
        foreach (int i in posNums) 
        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?
class access
{
    public int x;
    private int y;
    public  void cal(int a, int b)
    {
        x = a + 1;
        y = b;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        access obj = new access();   
        obj.cal(2, 3);
        Console.WriteLine(obj.x + " " + obj.y);     
    }
}

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()
    {
        char[] arr = { 'A', 'B', 'C', 'D', 'E' };
        fixed (char* P = arr)
        {
            int i;
            for (i = 0 ;i < 5 ;i++)
            if (*P % 2 == 0)
            ++*P;
            else
            (*P)++;
            Console.WriteLine(arr);
        }
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

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

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 = "Hello i love Csharp";
        StringBuilder s2 = new  StringBuilder(s1);
        Console.WriteLine(s1.Equals(s2));
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

A HashTable t maintains a collection of names of states and capital city of each state. Which among the following finds out whether "New delhi" state is present in the collection or not?

Select an option to see the answer and solution.