line 18, Beta b = (Beta) a // It is required to cast as you can not assign a super class reference to a subclass reference directly
line 19, a.foo(), b.foo() // Here you making use of super class reference (which is pointing to sub class object), subclass reference( which intern pointing to sub class object) to invoke foo() method. So, both will invoke subclass method.
Joined: Jun 09, 2013
Thank you Ganesh Jee... I understood clearly ..Cheers!!!