first of all you have to understand the meaning of dynamic polymorphism. The behaviour of the Object should be determined at runtime. In your code , by only watching the following line ,
a.test();
, one can't predict which method can be called. However as per your simple example , you can easily say that it might call Class B's test() method , But think it little bit in large scenario. Suppose Class A has lots of sub classes,say Class B, Class C, .. Class N and there is a method something like :
public void getResult(A object){
object.test();
}
In this example can you able to say which test() method should be called. So no body can predict.
This can only be determined at runtime.