10. Overloding and overriding.

Answers were Sorted based on User's Feedback



10. Overloding and overriding...

Answer / preetham

Overloading :

If you want to use same method in a different ways by using different method signatures.It should be in the same class.
In the below example there is no parameter passed in first time calling but same method we used with passing multiple parameters. This is what overloading means.
Ex: public void FirstMethod(){}
public void FirstMethod(int i, string s){}

Overriding :

It deals with two methods one in a parent class and one in a child class that have the same signature.
The method in parent class should be declared as virtual and the method in the derived class should be declared as override in their method signature. Every virtual method in the parent class should be override in the derived class.
Ex : public virtual void FirstMethod(){}
public override void FirstMethod(){}

Is This Answer Correct ?    2 Yes 2 No

10. Overloding and overriding...

Answer / pinki

Overloading methods
1.They appear in the same class or a subclass
2.They have the same name but, have different parameter
lists, and can have different return types.
An example of an overloaded method is print() in the
java.io.PrintStream class

Overriding methods
It allows a subclass to re-define a method it inherits from
it's superclass
overriding methods:
1. It appears in subclasses
2. They have the same name as a superclass method
3. They have the same parameter list as a superclass method
4. They have the same return type as as a superclass method
5. They have the access modifier for the overriding method
may not be more restrictive than the access modifier of the
superclass method

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net AllOther Interview Questions

Explain cache? : .NET Architecture

0 Answers  


If I'm developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users?

3 Answers   Hologic, Siebel,


Explain domestic architecture artifacts? : Dot net architecture

0 Answers  


Difference between abstract class and interface

100 Answers   Accenture, Altruist, Baba Group, CitiGroup, Fiserv, HCL, IBM, iGate, Infosys, Jean Martin, Karthik Industries, Microsoft, OnDLine, TCS,


how to kill user session ?

2 Answers  






What is difference between .net and visual studio?

0 Answers  


Can you Explain <mobile:link> element .net mobile with example? : Microsoft dot net mobile

0 Answers  


what is the use of SQL command builder class in C#.net? Explain how can we execute a stored procedure using C#.Net? What is the difference between .DLL and .EXE?

2 Answers  


Does .NET runtime offer Deterministic Destruction or not?

0 Answers   HCL,


Explain .net mobile input controls? : Microsoft dot net mobile

0 Answers  


What are end points, contract, address and bindings?

0 Answers  


Explain in-proc,out-proc and sql server.

4 Answers   G7 CR Technologies, Ness Technologies,


Categories