An example:
import java.util.*; public class JavaPolymorph { public void Print() { System.out.println( "JavaPolymorph"); } public static void main(String[] args) { JavaPolymorph j1 = new JavaPolymorph(); JavaPolymorph j2 = new SubJavaPolymorph(); j1.Print(); j2.Print(); } } public class SubJavaPolymorph extends JavaPolymorph { public void Print() { System.out.println( "SubJavaPolymorph"); } }
Giving the output:
JavaPolymorph
SubJavaPolymorph