Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the Difference between Overriding and overloading?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about rapid application development tool?

1014


Allowed program to auto-correct the database when loading a presentation.

2317


What is the source code for display the picture in button click event?

1197


Explain and brief about rapid application development tool?

1066


Which class allows an element to be accessed using unique key?

1005


difference between control and component more than one differences

3120


What is the difference between Namespace and Assembly?

1212


Is it necessary to have SQL server installed in your computer in order to create a service based database in vb.net?

2423


What is the difference between a "jagged array" and multidimensional array" ?can anyone show me it practically ?

1029


How to create a constant in vb.net?

1242


Explain how to achieve polymorphism in vb.net?

980


Name and explain some of the exclusive features which are present in vb?

1003


What are the technology areas that microsoft.net contains?

1061


What is trace in vb.net?

1074


What is code security?

1123