In our last blog, we see the effect of override method, super class’s method become unused. So we have to remove override process from our program. For that we have many solution like create overloading, using super class, dynamic method dispatch and final method. In this blog we will work on override the method.
Remove override : using overloading method
System.out.println(“Welcome in A”);
class B extends A
void method(int x) // overload
System.out.println(“Welcome in B”);
public static void main(String args)
B b1 = new B();
b1.method(); // Call to A Class
b1.method(0); // Call to B Class
Welcome in A
Welcome in B
In this program, we change parameter of method() function and create overload method. So we have to call both method() and method(int) function from main class and we get both the output.
Video available on YouTube.
If you have any query on blog example, you can directly comment us or subscribe in website
1004total visits,1visits today