Sunday, March 5, 2017

Method Overloading In Inheritance Java

Tags

If there is a method in subclass having same name as that of method in superclass but these have some difference in number and type of arguments then Method Overloading Takes place.

Code::
class d
{
    void show()
    {
        System.out.println("D's method");
    }
}
class e extends d
{
    void show(int x)
    {
        System.out.println("E's method");
    }
}
public class MethodOverriding {

    public static void main(String[] nt)
    {
        e ob=new e();
        ob.show();
        ob.show(67);
    }

}
Output: