adplus-dvertising

Welcome to the Miscellaneous Topics MCQs Page

Dive deep into the fascinating world of Miscellaneous Topics with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Miscellaneous Topics, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Miscellaneous Topics, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Miscellaneous Topics. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Miscellaneous Topics. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Miscellaneous Topics MCQs | Page 16 of 17

Explore more Topics under C# programming

Q151.
what will be the output of 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();
     }
 }
Discuss
Answer: (b).FBCDE
Q152.
What will be the output of given 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();
         }
     }
 }
Discuss
Answer: (a).p[10] :0, p[9] :9, p[8] :8โ€ฆ..p[1]:1
Q153.
What will be the output of the given code snippet?
class UnsafeCode
 {
     unsafe static void Main()
     {
         string str = "this is a test";
 
             fixed (char* p = str)
            {
                for (int i = str.Length-1 ;p[i] != 0 ;i--)
                Console.Write(p[i]);
            }
        Console.ReadLine();
    }
 }
Discuss
Answer: (c).tset a si siht
Q154.
What will be the output of given 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();
     }
 }
Discuss
Answer: (c).A True
Q155.
What will be the output of given 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();
   }
}
Discuss
Answer: (c).200
Q156.
What will be the output of given 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();
   }
}
Discuss
Answer: (b).120
Q157.
What will be the output of given 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();
        }
    }
}
Discuss
Answer: (c).p and p2 point to the same address
Q158.
What will be the output of given 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();
    }
}
Discuss
Answer: (c).Result has no value
Q159.
What will be the output of given 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();
    }
}
Discuss
Answer: (b).110
Discuss
Answer: (d).All of the mentioned

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!