Infolinks In Text Ads

Oct 20, 2010

method overloading and method overriding java

method overloading vrs method overriding

difference between method overloading and method overriding

Method Overloading:-
Method Overloading occurs with in the class. When any class have more than one method with same name and different parameter.
Class A{
public int add(int x, int y){
// implimentation
}
public String add(int x, int y, int z){
// implimentation
}
}



Method Overriding:-
Method Overriding occurs with in the Parant class and Child (Derived) class. When both class have same method name with same signature.
Class A{
public int add(int x, int y){
// implimentation
}
}



Class B extends A{
public int add(int x, int y){
// implimentation
}
}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...