Hello Friends, Here I am going to write some Interview Questions on Method and Property in .NET.

Interview Questions and Answers on Method and Property in.NET.

Method and Property

1. What’s the implicit name of the parameter that gets passed into the set method/property of a class?

Ans) Value. The data type of the value parameter is defined by whatever data type the property is declared as.

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

Ans) The method or property can be overridden.

3. How is method overriding different from method overloading?

Ans) When overriding a method, you change the behaviour 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?

Ans) 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?

Ans) Different parameter data types, the different number of parameters, different order of parameters.

6. If a 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?

Ans) 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.

View More:

Conclusion:

I hope this post about Interview Questions and Answers in Method and Property is useful for you. I would appreciate your feedback, comments, and suggestions

Thank You.

Leave a Comment