Saturday, June 23, 2018

WAP IN JAVA TO SHOW DYNAMIC METHOD DISPATCH

class Dmd
{
    public void show()
    {
        System.out.println("Method of super class");
    }
}
class T extends Dmd
{
    public void show()
    {
        System.out.println("Method of sub class");
    }
}
public class Fourteen {
    public static void main(String args[])
    {
        Dmd supob=new Dmd();
        T subob=new T();
        supob.show();
        subob.show();
        supob=subob;
        supob.show();
    }
 
}

No comments:

Post a Comment