• Tutorials
  • Courses
  • Tracks

Delegates and Events in C# Quiz

Last Updated :
Discuss
Comments

Question 1

What is a delegate in C#?

  • A type that stores variables

  • A type-safe function pointer that references and invokes methods

  • A class for event handling only

  • A method without a name

Question 2

Which operator is used to add multiple methods to a multicast delegate?

  • +=

  • -

  • *

  • ++

Question 3

What is the main purpose of anonymous methods in C#?

  • To replace delegates completely

  • To define a method without a name inline with delegate usage

  • To create events

  • To declare a class

Question 4

Which of the following is the correct syntax for declaring a delegate?

  • delegate void MyDelegate(string msg);

  • void delegate MyDelegate(string msg);

  • delegate MyDelegate void(string msg);

  • MyDelegate delegate void(string msg);

Question 5

Which statement is true about events in C#?

  • Events can be raised by any class

  • Events do not allow multiple subscribers

  • Events require custom delegates in all cases

  • Events are built on top of delegates and follow the publisher-subscriber model

Question 6

When using a delegate with a return type and multiple methods attached, which value is returned?

  • The sum of all method return values

  • The result of the first method in the list

  • The result of the last method in the invocation list

  • No value is returned

Question 7

What is the standard base class for event data in C# when no additional data is required?

  • CustomEventArgs

  • EventArgs

  • DelegateArgs

  • Notify

Question 8

How do you pass additional data with an event in C#?

  • By using a custom EventArgs class and EventHandler<TEventArgs>

  • By using an anonymous method only

  • By using a multicast delegate

  • By raising multiple events

Tags:

There are 8 questions to complete.

Take a part in the ongoing discussion