adplus-dvertising

Welcome to the Delegates and Generics MCQs Page

Dive deep into the fascinating world of Delegates and Generics with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Delegates and Generics, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Delegates and Generics, 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 Delegates and Generics. 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 Delegates and Generics. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Delegates and Generics MCQs | Page 4 of 7

Explore more Topics under C# programming

Q31.
Which among the following differentiates a delegate in C#.NET from a conventional function pointer in other languages?
Discuss
Answer: (d).none of the mentioned
Discuss
Answer: (a).delegates are not type safe
Discuss
Answer: (c).delegates provides wrappers for function pointers
Discuss
Answer: (b).delegate void del(int p, double k);
del d;
x s = new x();
d = new del(ref s.x);
d(8, 2.2f);
Q35.
Which of the following is the correct way to call the function abc() of the given class csharp given below?
class csharp
{
    public int abc(int a)
    {
        Console.WriteLine("A:Just do it!");
        return 0;
    }
}
Discuss
Answer: (c).delegate int del(int a);
del d;
csharp s = new csharp();
d = new del(ref s.fun);
d(10);
Q36.
Which of the following is the correct way to call the subroutine function abc() of the given class csharp given below?
class csharp
{
    void abc()
    {
        console.writeline("A:Just do it!");
    }
}
Discuss
Answer: (b).delegate void del();
del d;
csharp s = new csharp();
d = new del(ref s.abc);
d();
Q37.
What will be the output of the given code snippet below?
{
    delegate void A(ref string str);
    class sample
    {
        public static void fun( ref string a)
        {
            a = a.Substring( 7, a.Length - 7);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            A str1;
            string str = "Test Your C#.net skills";
            str1 = sample.fun;
            str1(ref str);
            Console.WriteLine(str);
        }
    }
}
Discuss
Answer: (c).ur C#.NET Skills
Q38.
What will be the output of the given code snippet below?
{
    delegate string F(string str);
    class sample
    {
        public static string fun(string a)
        {
            return a.Replace(',''-');
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            F str1 = new F(sample.fun);
            string str = str1("Test Your c#.NET skills");
            Console.WriteLine(str);
        }
    }
}
Discuss
Answer: (b).Test-Your-C#.NET-Skills
Discuss
Answer: (d).All of the mentioned
Discuss
Answer: (d).All of the mentioned
Page 4 of 7

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!