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

4/9

Page

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

What does preprocessor directive #if and #endif explains?

Select an option to see the answer and solution.

Which string operation does the below-mentioned method define?
public static string Concat(string str0, string str1)

Select an option to see the answer and solution.

Among the given collections which one is I/O index based?

Select an option to see the answer and solution.

Choose the class from which the namespace 'System.Type' is derived?

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 = 60; 
       p->b = 15; 
       int c = 30;
       Console.WriteLine("Value is : " + p->Sum()*c);
       Console.ReadLine();
   }
}

Select an option to see the answer and solution.

What does the following C# code set specify?
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase)

Select an option to see the answer and solution.

Which of these is used as default for a member of a class if no access specifier is used for it?

Select an option to see the answer and solution.

What is the process by which we can control what parts of a program can access the members of a class?

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 s1 = "olleH";
    string s2 = "olleh";
    if (s1 == s2)
    Console.WriteLine("Equal");
    else
    Console.WriteLine("Unequal");
    if (s1.Equals(s2))
    Console.WriteLine("Equal");
    else
    Console.WriteLine("Unequal");
    Console.ReadLine();
}

Select an option to see the answer and solution.

What kind of exception is being thrown if Wait(), Pulse() or PulseAll() is called from code that is not within synchronized code?

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 = 4.772;
        double y = 4.76;
        double z = Math.Max(x, y);
        Console.WriteLine(z);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class sum   
{
    public int x;
    public int y;
    public  int add (int a, int b)
   {
       x = a + b;
       y = x + b;
       return 0;
   }
}    
class Program
{
    static void Main(string[] args)
    {
        sum obj1 = new sum();
        sum obj2 = new sum();   
        int a = 2;
        obj1.add(a, a + 1);
        obj2.add(5, a);
        Console.WriteLine(obj1.x + "  " + obj2.y);     
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Which among the following is a correct statement about namespace used in C#.NET?

Select an option to see the answer and solution.

Consider an integer pointer . *a.++*a will increment . . . . . . . . while *a++ will increment . . . . . . . .

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 ;
        int ch = 13*5;
        p = &(ch);
        Console.WriteLine(Convert.ToChar(*p));
        if (*p == 'A')
        Console.WriteLine(Convert.ToBoolean(1));
        else
        Console.WriteLine(Convert.ToBoolean(0));
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What does the following C# code specify?
object Invoke(object obj, object[] parameters)

Select an option to see the answer and solution.

What does the following C# code set specifies?
public static int Compare(string strA, string strB)

Select an option to see the answer and solution.

Which of the following is not a namespace in the .NET Framework Class Library?

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)
    {
        float x = 3.14F;
        int y = (int)Math.Abs(x);
        Console.WriteLine(y);
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.

Which among the following is not the ordered collection class?

Select an option to see the answer and solution.