Delegates Questions and Answers
Practice ModeShowing 10 of 32 questions
Q21
What does the Action delegate represent?
Answer: Option B
Explanation: Action delegate represents a method that does not return a value.
Q22
What does the Func delegate represent?
Answer: Option A
Explanation: Func delegate represents a method that returns a value.
Q23
What is the Predicate delegate used for?
Answer: Option B
Explanation: Predicate delegate represents a method that takes one input and returns a boolean.
Q24
How do you remove a method from a multicast delegate?
Answer: Option B
Explanation: The - operator is used to remove a method from a multicast delegate.
Q25
What are anonymous methods in C#?
Answer: Option B
Explanation: Anonymous methods are inline methods without a name, defined using delegate keyword.
Q26
What are lambda expressions in C#?
Answer: Option B
Explanation: Lambda expressions provide a concise way to write anonymous methods using => operator.
Q27
Which event keyword is used with delegates?
Answer: Option B
Explanation: The event keyword is used to declare events that work with delegates.
Q28
What is the main advantage of using events over plain delegates?
Answer: Option C
Explanation: Events provide encapsulation and prevent external classes from invoking the delegate directly.
Q29
Can delegates be used for asynchronous programming?
Answer: Option B
Explanation: Yes, delegates support asynchronous invocation using BeginInvoke and EndInvoke.
Q30
What is covariance in delegates?
Answer: Option A
Explanation: Covariance allows a delegate to return a more derived type than specified in its signature.