// Dynamic poly, Method overriding(same name, different class, same arguments(type, sequence, number, IS-A relationship) class firstClass { void method1(int a) { System.out.println("1"); } } class secondClass extends firstClass{ void method1(String a) { System.out.println("2"); } public static void main(String[] args) { firstClass fc = new firstClass(); fc.method1(1); secondClass sc= new secondClass(); sc.method1(45); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter