Runtime Polymorphism ( Dynamic polymorphism)
It is also known as Dynamic Method Dispatch. Dynamic polymorphism is a process in which a call to an overridden method is resolved at runtime, thats why it is called runtime polymorphism. I have already discussed method overriding in detail in a separate tutorial, refer it: method overloading in javaclass Bank{float getdata()
{return 0;}
}
class SBI extends Bank{float getdata()
{return 5.6f; }
}
class PNB extends Bank{float getdata()
{ return 7.7f; }
}
class Barodra extends Bank{float getdata()
{return 9.7f; }
}
class TestDTM{
public static void main (String[]args)
{
Bank b;
b =new SBI();
System.out.println("SbI intrest persentage"+ b.getdata());
b =new PNB();
System.out.println("PNB intrest persentage"+ b.getdata());
b =new Barodra();
System.out.println("baroda intrest persentage"+ b.getdata());
}
}
0 comments:
Post a Comment