adplus-dvertising
frame-decoration

Question

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);

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);

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

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

Similar Questions

Discover Related MCQs

Q. 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.

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

Q. 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?

Q. Which of the following statements is incorrect about a delegate?

Q. 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?

Q. Which of the following statements is valid about generic procedures in C#.NET?

Q. Which of the following statements is valid about advantages of generics?

Q. The ‘ref’ keyword can be used with which among the following?

Q. To implement delegates, the necessary condition is?

Q. Suppose a Generic class called as SortObjects is to be made capable of sorting objects of any type(integer, single, byte etc).Then, which of the following programming constructs is able to implement the comparison function?

Q. To generate a simple notification for an object in runtime, the programming construct to be used for implementing this idea?

Q. Choose the incorrect statement among the following about the delegate?

Q. Which among the following is the correct statement about delegate declaration ?

delegate void del(int i);

Q. Which of the following is an incorrect statement about delegate?

Q. Which among the following differentiates a delegate in C#.NET from a conventional function pointer in other languages?

Q. Choose the incorrect statement about delegates?

Q. Which of the following statements is correct about a delegate?

Q. Choose the statements which makes delegate in C#.NET different from a normal class?

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

Q. Incorrect statements about delegates are?