Delegates Questions and Answers

Practice Mode
Showing 10 of 32 questions
Q21
What does the Action delegate represent?
  • A A method that returns a value
  • B A method that does not return a value
  • C A method that takes no parameters
  • D A method that handles exceptions
Answer: Option B
Explanation: Action delegate represents a method that does not return a value.
Q22
What does the Func delegate represent?
  • A A method that returns a value
  • B A method that does not return a value
  • C A method that takes no parameters
  • D A method that handles events
Answer: Option A
Explanation: Func delegate represents a method that returns a value.
Q23
What is the Predicate delegate used for?
  • A A method that returns a string
  • B A method that takes one input and returns boolean
  • C A method that sorts collections
  • D A method that handles user input
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?
  • A Using the Remove() method
  • B Using the - operator
  • C Using the Delete() method
  • D Using the / operator
Answer: Option B
Explanation: The - operator is used to remove a method from a multicast delegate.
Q25
What are anonymous methods in C#?
  • A Methods with unique names
  • B Inline methods without a name
  • C Static methods only
  • D Methods that cannot be called directly
Answer: Option B
Explanation: Anonymous methods are inline methods without a name, defined using delegate keyword.
Q26
What are lambda expressions in C#?
  • A A way to create named methods
  • B Concise way to write anonymous methods
  • C A type of loop expression
  • D A database query syntax
Answer: Option B
Explanation: Lambda expressions provide a concise way to write anonymous methods using => operator.
Q27
Which event keyword is used with delegates?
  • A delegate
  • B event
  • C handler
  • D subscribe
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?
  • A They are faster than delegates
  • B They use less memory
  • C They provide encapsulation and prevent direct invocation
  • D They automatically handle exceptions
Answer: Option C
Explanation: Events provide encapsulation and prevent external classes from invoking the delegate directly.
Q29
Can delegates be used for asynchronous programming?
  • A No, delegates are only for synchronous calls
  • B Yes, using BeginInvoke and EndInvoke
  • C Only in .NET Framework 4.0 and above
  • D Only for static methods
Answer: Option B
Explanation: Yes, delegates support asynchronous invocation using BeginInvoke and EndInvoke.
Q30
What is covariance in delegates?
  • A Returning more derived types
  • B Accepting more derived parameters
  • C Handling multiple return types
  • D Working with generic types only
Answer: Option A
Explanation: Covariance allows a delegate to return a more derived type than specified in its signature.
Questions and Answers for Competitive Exams Various Entrance Test