header1.html

Tuesday, 9 April 2013

C# Quiz-6(Events & Delegates)


C# Quiz-6(Events & Delegates)
1.A(an)...is the encapsulation of the idea that "something happened" to which the program must respond.
event
delegate
event-delegate model
None of above


2.-= operator is used to remove a delegate from a (possibly composite) field.
True
False


3. What will be output of following program?
delegate void MyDelegate(int i);
class Program
{
   public static void Main()
   {
      TakesADelegate(new MyDelegate(DelegateFunction));
   }
   public static void TakesADelegate(MyDelegate SomeFunction)
   {
      SomeFunction(21);
   }
   
   public static void DelegateFunction(int i)
   {
      System.Console.WriteLine("Called by delegate with number: {0}.", i);
   }
}

Compile time error
Called by delegate with number: 21.
Runtime error
None of above


4.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?
Attribute
Delegate
Namespace
Interface


5.Which of the following statements are correct about delegates?
Delegates cannot be used to call a static method of a class.
Delegates cannot be used to call procedures that receive variable number of arguments.
If signatures of two methods are same they can be called through the same delegate object.
Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine.


6.delegate is a....
reference type
value type
both
none of above


7.A delegate defines....
a means of passing arrays into methods
a substitue for an inherited method
a class that encapsulates methods
None of above


8.An Event is
The result of a users action
result of a party
code to force users action
None of above


9.An event declaration defines a type that encapsulates a method with a particular set of arguments and return type.
True
False


10.A delegate can either be called asynchronously by using BeginInvoke and EndInvoke methods.
True
False