What is the Difference between Overriding and overloading?
Answers were Sorted based on User's Feedback
Answer / venkatreddy
overriding:method name and signature are must be same.
overloading: functionality that enables you to define tow or more methods with the same name but with different signatures within the class the methods that share the same name ,but have different signature are called overloaded methods.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / neeraj sahu
Overloading : It is a feature of OOPs , by that we can
achieve run time polymorphism. To declare it we need the
same method name but different argument or different types
of argument.
Overriding : It is a feature of OOPs, By that we can achieve
compile time polymorphism.To declare it we need the same
method name and same types and same number of argument but
in different class.
| Is This Answer Correct ? | 5 Yes | 5 No |
Answer / aparna murthy
overloading is the ability to define several methods with
the same name ,provided each method has a different signature.
example:--
class shape
{
public void area(double r)
{
console.writeline("Area of circle :"+(3.14*r*r));
}
public void area(double l,double b)
{
console.writeline("Area of rectangle :"+(l*b));
}
public void area(int b,int h)
{
console.writeline("Area of rectangle :"+(0.5*b*h));
}
}
class program
{
static void main(string[]args)
{
shape s=new shape()
s.area(7,6)
s.area(22,11);
s.area(12,20);
console.read();
}
}
try this example.....
signature of a method is the datatype of the
parameters,number of parameters and the sequence in which
they are passed to the function .
overriding:---
In method overriding method have same names same signatures
same return types but in different scopes(classes) in
hierarchy .c# uses virtual and override keywords to define
method overriding .Method overriding enables object to
resolve method invocation at runtime.we call it late binding
behavior of object.
1.An override declaration cannot change the accesibility of
vitual method .Both the override method and the virtual
method must have the same access level modifier.
2.Methods which are to be overriden in the subsequent
derived class are made virtual or abstract in base class.
example:--
class employee
{
public virtual double calculatesalary()
{
return basic+hra+da;
}
}
class manager:employee
{
public override double calculatesalary()
{
return basic+hra+da+allowances;
}
}
static void main(string[] args)
{
employee mgr=new manager();
double salary=mgr.calculatesalary();
console.writeline(salary);
console.readline();
}
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / veena
overloading:-
-------------- function name same and parameters in the functions are different
class function
{
public string find_big(int a, int b)
{
//source code
}
public string find_big(float a, float b)
{
//source code
}
function overridding:-
------------------------in this function name same and the difference is inherits the 2nd class(derived class) from 1st class(base class)and
use the virtual to base class and override to derived class
virtual:-
----------
if we use virtual then the function calls once. it's c++ style
eg:-
class one
{
public virtual void display()
{
System.Console.WriteLine("one:display");
}
}
class two : one
{
public override void display()
{
System.Console.WriteLine("two:display");
}
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / mercy s
Method Overloading: It is the compile time polymorphism.
It has same method name but different parameters with in the
class
Method Overriding: It is the run time polymorphism. It has
same method name and same parameters but with in the name
space.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dhaval soni
Hi, friend My Name is Dhaval Soni
Thanks for giving me a chance for writing.
bye
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / jaya v. parmar
overloading:- Method name are same but argument are different.
overriding:- method,return type,argument are same but derived
class are different.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / m.usama
Overloading:
1.Methods having same name with different number of
parameters or different data type with same number of
parameter..
2. It is possible that overloading in inheritance..
Overriding:
1.The method in the derived class the has the
same name and same parameters in the base class and it
changes the behavior or functionality of the method in the
derived class,with overriding single reference of method is
created in memory of override function ..
2. Must be public.
3. possible in inheritance.
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / m.j
overloading:
argument list must diff.
return type can b dif.
overridding:
args list same
| Is This Answer Correct ? | 1 Yes | 3 No |
Explain the difference between value and reference types?
Name some of the features present in vb 2005?
Explain the advantage of option strict on?
What are the assembly entry points?
What is the use of errorprovider control?
Explain the use of console application?
Define manifest?
What are the differences between server-side and client-side code?
code for itemstockgroupwise record?
i had attended to infosys interview on 17th april 2010...on .net..3+ experience .. to my knowledge i did well in technical and they asked me to wait for next process ..so i waited for 15 min ..later one person came and said give 7-10 days time for intimation of next process do they keep technical and hr on different day ...or i loose the interview ..am confused yaar what accuatly would be happend
Can you please explain the difference between dataset and datareader?
What is the Difference between Overriding and overloading?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)