Delegates Questions and Answers

Practice Mode
Showing 10 of 32 questions
Q11
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?
  • A Namespace
  • B Interface
  • C Encapsulation
  • D Delegate
Answer: Option D
Q12
With which of the following can the ref keyword be used?     Static data     Instance data     Static function/subroutine     Instance function/subroutine
  • A 1, 2
  • B 3, 4
  • C 1, 3
  • D 2, 4
Answer: Option B
Q13
What is a delegate in C#?
  • A A class that contains only static methods
  • B A type-safe function pointer
  • C A special type of array
  • D A database connection object
Answer: Option B
Explanation: A delegate is a type-safe function pointer that defines a method signature.
Q14
Which keyword is used to define a delegate in C#?
  • A function
  • B delegate
  • C method
  • D pointer
Answer: Option B
Explanation: The delegate keyword is used to define a delegate type in C#.
Q15
What is the base class for all delegates in C#?
  • A System.Delegate
  • B System.MulticastDelegate
  • C System.Object
  • D System.ValueType
Answer: Option B
Explanation: System.MulticastDelegate is the base class for all delegate types in C#.
Q16
Which of the following is true about delegates?
  • A They are not type-safe
  • B They can point to only one method at a time
  • C They are type-safe and can point to multiple methods
  • D They cannot be used with events
Answer: Option C
Explanation: Delegates are type-safe and can point to multiple methods.
Q17
What is multicast delegate in C#?
  • A A delegate that can call methods on multiple objects
  • B A delegate that can hold references to multiple methods
  • C A delegate that works with multiple threads
  • D A delegate that can handle multiple exceptions
Answer: Option B
Explanation: A delegate that can hold references to multiple methods and invoke them in sequence.
Q18
How do you combine multiple delegates into one?
  • A Using the Combine() method
  • B Using the + operator
  • C Using the Merge() method
  • D Using the & operator
Answer: Option B
Explanation: The + operator is used to combine delegates in C#.
Q19
What happens when a multicast delegate is invoked?
  • A Only the first method is called
  • B Methods are called in reverse order
  • C All methods are called in the order they were added
  • D A random method is selected and called
Answer: Option C
Explanation: All methods referenced by the delegate are called in the order they were added.
Q20
Which of these is NOT a built-in delegate in C#?
  • A Action
  • B Func
  • C FuncDelegate
  • D Predicate
Answer: Option C
Explanation: FuncDelegate is not a built-in delegate type in C#.
Questions and Answers for Competitive Exams Various Entrance Test