Override:
Within a class hierarchy, when a method in a subclass has the similar name and type signature as a method in its superclass after that the method in the subclass, subclass is said to override the method in the superclass. Whenever an overridden function is called from inside a subclass, it will always refer to the version of which method defined through the superclass will be hidden consider the subsequent:
 
// method overriding class A
 
{
 
int i,j;
 
A(int a, int b) { I=a;
 
J=b;
 
}
 
//display i and j void show() {
 
System.out.println("i and j: " +i " " + j);
 
}
 
}
 
class B extends A{
 
int k;
 
B(int a, int b, int c) {
 
super(a,b);
 
k=c;
 
}
 
// display k - this overrides show() in a
 
void show() {
 
System.out.println("k: "+k);
 
}
 
}
 
class override {
 
public static void main(String a[]) {
 
B subOb = new b(1,2,3);
 
SubOb.show();
 
}
 
}
The output of this program is
K: 3