Method Overriding:
When child class have same method which is declare in parent class is called method overriding.
Note:
//Requirement first --understanding concept of inheritance
//please refer inheritance tutorial first for easy understanding
Rules:
Child class method must be same as parent class method.
child class must extends parent class.
Example:
class college{
void show(){
System.out.println(" method of parent class");
}
}
//implement single inheritance by using extends keyword
class student4 extends college{
void show(){
System.out.println(" method of child class");
}
public static void main(String args[]){
student4 s=new student4();
s.show();
}
}
OUTPUT:
Method of child class