java - Abstract class and dynamic binding -
so i've been studying abstract classes , dynamic binding , decided test out couple of examples. i have following 3 classes: abstractdemo (main), myabstract , mysubabstract. main method calling methods both classes using dynamic or static binding. all of following calls work except last 1 try use dynamic binding , call 1 of methods defined in subclass (sub1()). assume despite being declared reference of superclass object still able find method declared within object's class. can please explain why? public abstract class myabstract { public abstract void abs1(); public abstract void abs2(); public void nonabs1() { system.out.println("myabstract nonabs1"); } public void nonabs2() { system.out.println("myabstract nonabs2"); } } public class mysubabstract extends myabstract { public void abs1() { system.out.println("mysubabstract abs1()"); } public void abs2() { system.out.println("mysubabstract abs2