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

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java