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 1 of 7

Explore more Topics under C# programming

Discuss
Answer: (d).Only one method can be called using a delegate.
Q2.
In which of the following areas are delegates commonly used?

1. Remoting
2. Serialization
3. File Input/Output
4. Multithreading
5. Event handling
Discuss
Answer: (d).4 and 5 only
Q3.
Which of the following is the necessary condition for implementing delegates?
Discuss
Answer: (a).Class declaration
Q4.
Which of the following statements are correct about the delegate declaration given below?

delegate void del(int i);

1. On declaring the delegate a class called del will get created.
2. The signature of del need not be same as the signature of the method that we intend to call using it.
3. The del class will be derived from the MulticastDelegate class.
4. The method that can be called using del should not be a static method.
5. The del class will contain a one-argument constructor and an lnvoke() method.

    
Discuss
Answer: (b).1, 3 and 5 only
Discuss
Answer: (d).delegate int del(int i);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10);
Discuss
Answer: (b).delegate void del(int i, Single j);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10, 1.1f);
Q7.
Which of the following statements are correct about a delegate?

1. Inheritance is a prerequisite for using delegates.
2. Delegates are type-safe.
3. Delegates provide wrappers for function pointers.
4. The declaration of a delegate must match the signature of the method that we intend to call using it.
5. Functions called using delegates are always late-bound.
 
Discuss
Answer: (c).2, 3 and 4 only
Q8.
Which of the following statements are correct about delegates?

1. Delegates are not type-safe.
2. Delegate is a user-defined type.
3. Only one method can be bound with one delegate object.
4. Delegates can be used to implement callback notification.
5. Delegates permit execution of a method on a secondary thread in an asynchronous manner.
Discuss
Answer: (c).2, 4 and 5 only
Discuss
Answer: (b).Delegates cannot be used to call procedures that receive variable number of arguments.
Q10.
Which of the following are the correct ways to declare a delegate for calling the function func() defined in the sample class given below?

class Sample
{
    public int func(int i, Single j)
    {
        /* Add code here. */
    }
}
Discuss
Answer: (c).delegate int d(int i, Single j);
Page 1 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!