Delegates and Events Questions and Answers

1. ) What do you mean by call-back method?                                                                 
In object -oriented programming, one object send to message to other objects,The methods are used to callback message are known as callback methods.
     C# implements the callback technique in much safer and more object oriented manner,using the help of delegate objects.

2. ) What is the 'type safe' information?                                                                          
  • Number of parameters
  • Types of parameters
  • Return type
  • Calling convention
3. ) What are the main purpose to use the delegate objects?                                      
  • Callback
  • Event Handling
4. ) What are class used for delegate declaration?                                                         

5. ) What is delegate in c# ?                                                                                               
A delegate in c# is a class type object that is used to encapsulate the method call and invoke a method at the time of its creation.
Delegate means "a person acting for another person" or "a method acting for another method".

6. ) What are the steps involved for creating a delegate ?                                           
  • Delegate declaration
  • Delegate method definition
  • Delegate object declaration
  • Delegate invocation(calling)
7. ) Through delegate only that function can be called whose signature and Return type is same as delegate ?                                           
More Details..
8. ) What is the syntax for declaration of the delegate ?                                             
<access-specifier><delegate keyword><return type><delegate-name><parameter-list>
public delegate void del();

9. ) What are the modifier(access-specifier) used to control the accessibility of the delegate ?
  • Public
  • protected
  • internal
  • private
  • New
Note:-The new modifier is only used on delegates declared within another type.

10. ) Where we can define the delegates ?                                                                       
  • Inside a class
  • outside the class
  • As a top level object in a namespace
11. ) What are the delegate types implicitly defined in c# ?                                         

12. ) What is delegate method and how to declare it ?                                                  
A method whose references is encapsulated into a delegate instance is known as delegate methods.
A method which will be called by the delegate ,is known as delegate methods.
public class student
public void show()
{"Hello Friends");

13. ) What is the delegate object declaration in c# ?                                                    
We have already seen,a delegate is a class type and behave like a class. 
delegate-name delegate-object = new delegate-name(expression)
student obj =new student();
del delobj =new del(;

14. ) What is the delegate invocation in c# ?                                                                 
delegate-object (parameter-list);
15. ) What are the types of delegates in c# ?                                                                   
There are two types of delegate in c #.
  • Single cast delegate
  • Double cast delegate
16. ) What is the single cast delegate ?                                                                             
One delegate object can call only one method, is known as single cast delegate.

17. ) What is the multi cast delegate in c# ?                                                                    
One delegate object can call more than one method in sequence ,is known as  multicast delegate.

18. ) What is the anonymous  method in context of delegate?                                   
The collection of methods directly pass the delegate,is known as anonymous method.
More Details..

19. ) What is event in c#?                                                                                                    
A  Event is a kind of notification(information) giving one by one object to another object to perform task.
More Details..

20. ) What is the syntax of event declaration ?                                                              
public event del myevent;
More Details..

21. ) What is the Event handler in c# ?                                                                            
Event handler is a method which is used for handling the events.

22. ) Are events are fully based on the delegates ?                                                        
Yes.We can not handle the events without delegates


Post a Comment

Powered by Blogger.