Delegates Questions and Answers

Take Exam

Delegates in C# are powerful constructs that allow methods to be passed as parameters, forming the foundation for event handling and lambda expressions. This section contains C# programming questions and answers focusing on delegate declaration, invocation, and multicast behavior. These C# delegates questions with answers are commonly asked in Infosys, TCS, and Capgemini technical interviews. Understanding delegates enhances your grasp of advanced C# features like events and asynchronous programming, which are key to writing flexible, maintainable applications.

Delegates

Showing 10 of 32 questions

21. What does the Action delegate represent?

  • A method that returns a value
  • A method that does not return a value
  • A method that takes no parameters
  • A method that handles exceptions
Show Answer Report

22. What does the Func delegate represent?

  • A method that returns a value
  • A method that does not return a value
  • A method that takes no parameters
  • A method that handles events
Show Answer Report

23. What is the Predicate delegate used for?

  • A method that returns a string
  • A method that takes one input and returns boolean
  • A method that sorts collections
  • A method that handles user input
Show Answer Report

24. How do you remove a method from a multicast delegate?

  • Using the Remove() method
  • Using the - operator
  • Using the Delete() method
  • Using the / operator
Show Answer Report

25. What are anonymous methods in C#?

  • Methods with unique names
  • Inline methods without a name
  • Static methods only
  • Methods that cannot be called directly
Show Answer Report

26. What are lambda expressions in C#?

  • A way to create named methods
  • Concise way to write anonymous methods
  • A type of loop expression
  • A database query syntax
Show Answer Report

27. Which event keyword is used with delegates?

  • delegate
  • event
  • handler
  • subscribe
Show Answer Report

28. What is the main advantage of using events over plain delegates?

  • They are faster than delegates
  • They use less memory
  • They provide encapsulation and prevent direct invocation
  • They automatically handle exceptions
Show Answer Report

29. Can delegates be used for asynchronous programming?

  • No, delegates are only for synchronous calls
  • Yes, using BeginInvoke and EndInvoke
  • Only in .NET Framework 4.0 and above
  • Only for static methods
Show Answer Report

30. What is covariance in delegates?

  • Returning more derived types
  • Accepting more derived parameters
  • Handling multiple return types
  • Working with generic types only
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test