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 over loading and over ridding?

Answer Posted / manish kushwaha

Hi All,
These two are very powerful concept in Java. I would like
to explain in veru simple way hope we will get it easily

1) Method OverLoading...
Always this concept comes with Same Name of methods

1) Mthod name should be same
2) Return type can be differ of methods
3) Most Important Condition is
a) Type of Parameter in methods
b) Number of paramenter in methods
c) Order of parameter in methods

Exp. 1 public void foo(String str a, int b){}
2 public int foo(int a, int b, int c){ }
3 public void foo(int a , double b){}
4 public void foo(double b , int a){}
5 public int foo(int a, int b, int c, int
d){ }

Like in above example one method can have any TYPE
of PARAMETER, 2,5 example of NUMBER of PARAMETER, 3,4
example of ORDER of parameter.
**Make sure that method overriding can be done in
same class and Sub/Super class both


2) Method Overriding.
Always method over riding happens only in Sub/Super
class concept
We have one method in super class and same method
in sub class with
1) Same mthod name
2) same method return type
3) same type of parameter
if above condition match then you can say this is
method over ring.....

Exp. Class A{
public int foo(int a, int b){}
}
Class B extends A{
public int foo(int d, int e){}
}
obove scenario is method over riding.

* Always Method overloading happens in Compile time
* Always method over riding happens in Run time.


Hope you got the concept.....
Thanks Manish

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is overloading in oop?

959


What is overloading and its types?

1079


What is object-oriented programming? Webopedia definition

1179


what are the realtime excercises in C++?

2784


Is this job good for future? can do this job post grduate student?

2092


Why do we use polymorphism in oops?

983


What is for loop and its syntax?

1034


Explain the concepts involved in Object Oriented programming.

1144


Why is encapsulation used?

948


What is an example of genetic polymorphism?

1117


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

3174


What are the three parts of a simple empty class?

1980


write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

2193


What is polymorphism and types?

1042


Please send ford technologies placement paper 2 my mail id

2057