Exercise: Delegates

Questions for: Delegates

With which of the following can the ref keyword be used?
  1. Static data
  2. Instance data
  3. Static function/subroutine
  4. Instance function/subroutine
A:
1, 2
B:
3, 4
C:
1, 3
D:
2, 4
Answer: B
No answer description is available. Let's discuss.
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: D
No answer description is available. Let's discuss.
Which of the following statements is incorrect about a delegate?
A:
A single delegate can invoke more than one method.
B:
Delegates can be shared.
C:
Delegate is a value type.
D:
Delegates are type-safe wrappers for function pointers.
Answer: C
No answer description is available. Let's discuss.
Suppose on pushing a button an object is to be notified, but it is not known until runtime which object should be notified. Which of the following programming constructs should be used to implement this idea?
A:
Attribute
B:
Delegate
C:
Namespace
D:
Interface
Answer: B
No answer description is available. Let's discuss.
Which of the following are the correct ways to declare a delegate for calling the function func() defined in the sample class given below?
class Sample
{
    public int func(int i, Single j)
    {
        /* Add code here. */
    }
}
A:
delegate d(int i, Single j);
B:
delegate void d(int, Single);
C:
delegate int d(int i, Single j);
D:
delegate void (int i, Single j);
Answer: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz