A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. Which of the following statements is incorrect about delegate?
a. Delegates are reference types.
b. Delegates are object oriented.
c. Delegates are type-safe.
d. Only one method can be called using a delegate.
View Answer Report Discuss Too Difficult!
Answer: (d).Only one method can be called using a delegate.

2. In which of the following areas are delegates commonly used?

1. Remoting
2. Serialization
3. File Input/Output
4. Multithreading
5. Event handling
a. 1 and 2 only
b. 1 and 5 only
c. 1, 2 and 3 only
d. 4 and 5 only
View Answer Report Discuss Too Difficult!
Answer: (d).4 and 5 only

3. Which of the following is the necessary condition for implementing delegates?
a. Class declaration
b. Inheritance
c. Run-time Polymorphism
d. Exceptions
View Answer Report Discuss Too Difficult!
Answer: (a).Class declaration

4. Which of the following statements are correct about the delegate declaration given below?

delegate void del(int i);

1. On declaring the delegate a class called del will get created.
2. The signature of del need not be same as the signature of the method that we intend to call using it.
3. The del class will be derived from the MulticastDelegate class.
4. The method that can be called using del should not be a static method.
5. The del class will contain a one-argument constructor and an lnvoke() method.

    
a. 1, 2 and 3 only
b. 1, 3 and 5 only
c. 2 and 4 only
d. 4 only
View Answer Report Discuss Too Difficult!
Answer: (b).1, 3 and 5 only

5. Which of the following is the correct way to call the function MyFun() of the Sample class given below?

class Sample
{
    public int MyFun(int i)
    {
        Console.WriteLine("Welcome to CompSciBits.com !" );
        return 0;
    }
}
a. delegate void del(int i);
Sample s = new Sample();
deld = new del(ref s.MyFun);
d(10);
b. delegate int del(int i);
Sample s = new Sample(.);
del = new delegate(ref MyFun);
del(10);
c. Sample s = new Sample();
delegate void del = new delegate(ref MyFun);
del(10);
d. delegate int del(int i);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10);
View Answer Report Discuss Too Difficult!
Answer: (d).delegate int del(int i);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10);

6. Which of the following is the correct way to call subroutine MyFun() of the Sample class given below?

class Sample
{
    public void MyFun(int i, Single j)
    {
        Console.WriteLine("Welcome to CompSciBits !");
    }
}
a. delegate void del(int i);
Sample s = new Sample();
del d = new del(ref s.MyFun);
d(10, 1.1f);
b. delegate void del(int i, Single j);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10, 1.1f);
c. Sample s = new Sample();
delegate void d = new del(ref MyFun);
d(10, 1.1f);
d. delegate void del(int i, Single]);
Sample s = new Sample();
del = new delegate(ref MyFun);
del(10, 1.1f);
View Answer Report Discuss Too Difficult!
Answer: (b).delegate void del(int i, Single j);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10, 1.1f);

7. Which of the following statements are correct about a delegate?

1. Inheritance is a prerequisite for using delegates.
2. Delegates are type-safe.
3. Delegates provide wrappers for function pointers.
4. The declaration of a delegate must match the signature of the method that we intend to call using it.
5. Functions called using delegates are always late-bound.
 
a. 1 and 2 only
b. 1, 2 and 3 only
c. 2, 3 and 4 only
d. All of the above
View Answer Report Discuss Too Difficult!
Answer: (c).2, 3 and 4 only

8. Which of the following statements are correct about delegates?

1. Delegates are not type-safe.
2. Delegate is a user-defined type.
3. Only one method can be bound with one delegate object.
4. Delegates can be used to implement callback notification.
5. Delegates permit execution of a method on a secondary thread in an asynchronous manner.
a. 1 and 2 only
b. 1, 2 and 3 only
c. 2, 4 and 5 only
d. 4 and 5 only
View Answer Report Discuss Too Difficult!
Answer: (c).2, 4 and 5 only

9. Which of the following statements are correct about delegates?
a. Delegates cannot be used to call a static method of a class.
b. Delegates cannot be used to call procedures that receive variable number of arguments.
c. If signatures of two methods are same they can be called through the same delegate object.
d. Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine.
View Answer Report Discuss Too Difficult!
Answer: (b).Delegates cannot be used to call procedures that receive variable number of arguments.

10. 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);
View Answer Report Discuss Too Difficult!
Answer: (c).delegate int d(int i, Single j);

Page 1 of 7