METHOD OVERRIDING IN JAVA IN THE SIMPLEST TERM
Consider the following code. Here the child class inherits the method from parent class. Now when we create the object of child class by commenting its method, we can call the method of parent class and the output shows "In parent class". But when we write same method in the child class but different printing operation, we get the output as "In child class". That is called method overriding. The child class method overrides the parent class method.
package Polymorphism;
class parent{
public void display() {
System.out.println("In parent class");
}
}
class child extends parent{
/*
public void display() {
System.out.println("In child class");
}
*/
}
public class MethodOverriding {
public static void main(String[] args) {
child ch1=new child();
ch1.display();
}
}

Now I had the comment removed.

If you want to display the output of both the class then you can use "super" keyword. And you should use it in the class that is overriding the another class.
Thanks for sharing an other Java tutorial to make it easier for other user. Keep it up your good. It will be helpful for s
Pread of knowledge and growth of this community.
Your post has been submitted to be curated with @gitplait community account because this is the kind of publications we like to see in our community.
Join our Community on Hive and Chat with us on Discord.
[Gitplait-Team]