Dynamic Method invocation (Objects and reference in inheritance )
问题 Suppose I have 2 classes ........ A Class is base class and class B is derived class and if i create a reference such as : A a=new B(); does it mean that reference a points to object of B Class ? If yes than how am i able to call overridden methods of A in B and not other methods of B ? thank you in advance class A { m1() { } } class B extends A { m1() { } m2() { } } A a=new B(); a.m1(); //it will call overridden m1() in B a.m2(); //it doesnt work if reference "a" points to object of B than