C#.Net Interview Question and Answers

101. What is the difference between Shadowing and Overriding?
 
  • Overriding redefines only the implementation while shadowing redefines the whole element.
  • In overriding derived classes can refer the parent class element by using "ME" keyword, but in shadowing you can access it by "MYBASE".
 
Your Name Your Email-ID
Your Answer
102. Can events have access modifiers?
  Yes, you can have access modifiers in events. You can have events with the protected keyword, which will be accessible only to inherited classes. You can have private events only for objects in that class.
 
Your Name Your Email-ID
Your Answer
103. Why is the virtual keyword used in code?
  The Virtual keyword is used in code to define methods and the properties that can be overridden in derived classes.
 
Your Name Your Email-ID
Your Answer
104. What are constructors and destructors?
 
  • Constructors and destructors are special methods.
  • Constructors and destructors are special methods of every class.
  • Each class has its own constructor and destructor and are called automatically when the instance of a class is created or destroyed.
  • The constructor initializes all class members whenever you access the class and the destructor destroys them when the objects are not required anymore.
 
Your Name Your Email-ID
Your Answer
105. How can we suppress a finalize method?
  GC.SuppressFinalize()
 
Your Name Your Email-ID
Your Answer