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

8/9

Page

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

What is meant by preprocessor directive #define?

Select an option to see the answer and solution.

Choose the correct statements for the following C# code?
public System.Collections.IEnumerator GetEnumerator()
{
    foreach (char ch in chrs)
    yield return ch;
}

Select an option to see the answer and solution.

Which among the given is not a correct way to call the method Issue() defined in the following C# code snippet?
class Book
{
    public void issue()
    {
      /* code */
    }
}
class Journel
{
     public void issue()
     {
         /* code */
     }
}

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 = null;
        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 is Semaphore?

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
#define DEBUG 
#undef DEBUG
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)
            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.

What will be the output of the following C# code snippet?
class UnsafeCode
{
    struct MyStruct
    {
        public int a;
        public int b;
        public int Sum() 
       { 
           return a * b; 
       }
   }
   unsafe static void Main()
   {
       MyStruct o = new MyStruct();
       MyStruct* p; 
       p = &o;
       p->a = 10; 
       p->b = 20; 
       Console.WriteLine("Value is " + p->Sum());
       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* a;
        int a1 = 10;
        int b1;
        b1 = *&a1;
        a = &b1;
        {
            Console.WriteLine(*a);
            Console.ReadLine();
        }
    }
}

Select an option to see the answer and solution.

Which of these keywords are used to implement synchronization?

Select an option to see the answer and solution.

Among the given pointer which of the following cannot be incremented?

Select an option to see the answer and solution.

Choose the correct statement about System.Type namespace.

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class test
{
    public   int a;
    public  int b;
    public  test(int i, int j)
    {
        a = i;
        b = j;
    }
    public void meth(test o)
    {
        o.a *= 2;
        o.b /= 2;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        test obj = new test(10, 20);
        obj.meth(obj);
        Console.WriteLine(obj.a + " " + obj.b);    
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Which among the following statements are not correct about a namespace used in C#.NET?

Select an option to see the answer and solution.

Which among the following is referred as an array of pointers?

Select an option to see the answer and solution.

How many values can be returned from a function simultaneously using pointers?

Select an option to see the answer and solution.

Which of these classes contains only floating point functions?

Select an option to see the answer and solution.

Which among the given statements are correct about the Stack collection?

Select an option to see the answer and solution.

Which among the given operators is referred to as 'address of' operator?

Select an option to see the answer and solution.

Which among the following does not belong to the C#.NET namespace?

Select an option to see the answer and solution.

What is the size of a char pointer?

Select an option to see the answer and solution.