class Demo { void show() { System.out.println("hi"); } void show() { System.out.println("welcome"); } void show() { System.out.println("java"); } } public class Main { public static void main(String args[]) { Demo d=new Demo(); d.show(); } }
Error: method show already existing in the Demo class.
Note:
But Here PolyMorphism means same method name existing multiple times.But here if you take same method name multiple error will displayed.To overcome this problems overloading and overridding are introduced.