Monday, October 26, 2020

C# Interview Questions (Method and Property )

 



 

Method and Property Questions 


1. What’s the implicit name of the parameter that gets passed into the set method/property of a class? 
Value. The data type of the value parameter is defined by whatever data type the property is declared.

2. What does the keyword “virtual” declare for a method or property? 
The method or property can be overridden. 

3. How is method overriding different from method overloading? 
When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class. 

4. Can you declare an override method to be static if the original method is not static? 
No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override) 

5. What are the different ways a method can be overloaded? 
Different parameter data types, different the number of parameters, different order of parameters. 

6. If the base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

No comments:

Post a Comment

NET Core Code Security, Authorization/Authentication, and code architecture

Complex NET Core interview questions (Code Security, Authorization/Authentication, and code architecture)  _________________________________...