Java Program To Show Dynamic polymorphism
Chapter:
Interview Programs
Last Updated:
20-06-2016 19:12:22 UTC
Program:
/* ............... START ............... */
public class JavaDynamicPolymorphismExample {
public void show(int a) {
System.out.println("Harry");
}
public void show(int a, int b) {
System.out.println("Joy");
}
public void show(float a) {
System.out.println("Steve");
}
public static void main(String args[]) {
JavaDynamicPolymorphismExample a = new JavaDynamicPolymorphismExample();
a.show(10);
a.show(1, 2);
a.show(1.2f);
}
}
/* ............... END ............... */
Notes:
-
Polymorphism means defining multiple methods with same name.
- Two types of polymorphism
- 1.Static polymorphism
- 2.Dynamic polymorphism.
Tags
Dynamic polymorphism, Java, Interview Programs