C# Delegates MCQ Set-1

Errorlogger
1
1. Among from the following ‘ref’ keyword can be used with?
a) static function/subroutine
b) static data
c) Instance function/subroutine
d) instance data



2. To implement delegates the necessary condition for implementation is?
a) class decleration
b) inheritance
c) run time polymorphism
d) exceptions



3. Suppose a Generic class called as SortObjects is to made capable of sorting objects of any type(integer, single, byte etc).Hence, which following programming
construct is able to implement the comparision function?
a) interface
b) encapsulation
c) delegate
d) attribute



4. To generate a simple notification for an object on runtime the programming construct to be used for implementation this idea?
a) namespace
b) interface
c) delegate
d) attribute



5. Choose the incorrect statement about the delegate?
a) delegate are of reference types
b) delegates are object oriented
c) delegates are type safe
d) none of the mentioned



6. Correct statement about delegate declaration given below is ?
delegate void del(int i);
a) On declaring the delegate a class called del is created
b) the del class is derived from the MulticastDelegate class
c) the del class will contain a one arguement constructor and an invoke() method
d) none of the mentioned
e) both a and b



7. Which is the incorrect statement about delegate?
a) A single delegate can invoke more than one method
b) delegates could be shared
c) delegates are type safe wrappers for funtion pointers
d) delegate is a value type



8. Choose statements which differentiate delegate in C#.NET than a conventional function pointer in other languages?
a) delegate in C#.NET represent a new type in the Comman Type System
b) delegate allow static as well as instance methods to be invoked
c) delegate are type safe and secure
d) none of the mentioned



9. Choose incorrect statement about the delegates?
a) delegates are not type safe
b) delegates cannot be used to implement callback notification
c) delegates is a user defined type
d) delegates permits execution of a method on in an asynchronous manner
e) both a and b



10. Which statement is correct about a delegate?
a) inheritance is a prerequisite for using delegates
b) delegates are type safe
c) delegates provides wrappers for function pointers
d) both b and c
e) none of thee mentioned

Tags

Post a Comment

1Comments

  1. 7. Which is the incorrect statement about delegate?
    a) A single delegate can invoke more than one method
    b) delegates could be shared
    c) delegates are type safe wrappers for function pointers
    d) delegate is a value type

    Correct Answer should be : option D) delegate is value type.

    Explanation : A delegate is a reference type that can be used to encapsulate a named or an anonymous method. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.

    Reference : https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#:~:text=A%20delegate%20is%20a%20reference,are%20type%2Dsafe%20and%20secure.

    ReplyDelete
Post a Comment

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !