What is the Difference between Overriding and overloading?

Answers were Sorted based on User's Feedback



What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

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

What is the Difference between Overriding and overloading? ..

Answer / d

cv

Is This Answer Correct ?    7 Yes 9 No

What is the Difference between Overriding and overloading? ..

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

Post New Answer

More VB.NET Interview Questions

Explain option explicit?

0 Answers  


difference between control and component more than one differences

0 Answers  


Explain the difference between system.string and system.stringbuilder classes?

0 Answers  


Is vb net a scripting language?

0 Answers  


The default back end of the VB is

1 Answers   Hexaware,






What are the differences between server-side and client-side code?

0 Answers  


Explain convert.tostring and i.tostring method?

0 Answers  


Explain and brief about rapid application development tool?

0 Answers  


Explain jit?

0 Answers  


Explain i.tostring method?

0 Answers  


Explain namespace?

0 Answers  


Where is the Version Information Stored on a assembly ? Write the Namespace to load assemblies at runtime Can you allow a class to be inherited but prevent the method from being overridden ? What happens in memory when you box and unbox a value type ? Write a progtam to convert decimal to byte without using library function.

2 Answers   HCL,


Categories