Delegates Questions and Answers
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
11. Suppose a Generic class called SortObjects is to be made capable of sorting objects of any type (Integer, Single, Byte etc.). Which of the following programming constructs should be used to implement the comparision function?
- Namespace
- Interface
- Encapsulation
- Delegate
12. With which of the following can the ref keyword be used? Static data Instance data Static function/subroutine Instance function/subroutine
- 1, 2
- 3, 4
- 1, 3
- 2, 4
13. What is a delegate in C#?
- A class that contains only static methods
- A type-safe function pointer
- A special type of array
- A database connection object
14. Which keyword is used to define a delegate in C#?
- function
- delegate
- method
- pointer
15. What is the base class for all delegates in C#?
- System.Delegate
- System.MulticastDelegate
- System.Object
- System.ValueType
16. Which of the following is true about delegates?
- They are not type-safe
- They can point to only one method at a time
- They are type-safe and can point to multiple methods
- They cannot be used with events
17. What is multicast delegate in C#?
- A delegate that can call methods on multiple objects
- A delegate that can hold references to multiple methods
- A delegate that works with multiple threads
- A delegate that can handle multiple exceptions
18. How do you combine multiple delegates into one?
- Using the Combine() method
- Using the + operator
- Using the Merge() method
- Using the & operator
19. What happens when a multicast delegate is invoked?
- Only the first method is called
- Methods are called in reverse order
- All methods are called in the order they were added
- A random method is selected and called
20. Which of these is NOT a built-in delegate in C#?
- Action
- Func
- FuncDelegate
- Predicate