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

Difference between overloading and Overriding. <Giving a
confusing example to test the concept.>
(also asked in PA Consultancy Group,iflex,Value
chain,IBM,CTS,Accenture, Tarang>

Answer Posted / ravikant baluni

Method overloading:
-------------------
Method overloading means having two or
more methods with the same name but different signatures in
the same scope. These two methods may exist in the same
class or anoter one in base class and another in derived
class.

Like if we have a method: void sum(int a,int b){---} then
it can be overloaded as:
void sum(int a,int b,int c);
void sum(string s1,string s2);

Method overriding:
------------------
Method overriding means having a
different implementation of the same method in the
inherited class. These two methods would have the same
signature, but different implementation. One of these would
exist in the base class and another in the derived class.
These cannot exist in the same class.

Like if we have a method: int fun(int a,int b){---} then it
can be overrided as:
int fun(int a,int b)
{
return (a+b);
}



int fun(int a,int b)
{
return (a*b);
}


int fun(int a,int b)
{
return (a/b);
}

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why java is considered as platform independent?

998


Why bytecode is called bytecode?

1190


What are the steps that are followed when two computers connect through tcp?

987


What is the difference between applet and application?

1008


Why we use methods in java?

985


What are synchronized methods ?

1109


Can you have two constructors in java?

972


What does n mean in java?

964


How does multithreading take place on a computer with a single cpu in java programming?

1013


What is the default value of float and double datatype in java?

1010


What is the collections api in java programming?

976


What is a vector in java?

1023


What is finally and finalize in java?

1087


Can we assign null to double in java?

1011


When can you say a graph to be a tree?

1081