class AA {
void run()
{
System.out.print("In AA");
}
}
class B extends AA{
void run()
{
System.out.print("In B");
}
public static void main(String z[])
{
//upcasting
AA a= new B();
a.run();
}
}
Upcasting here working fine but now i m trying to call Parent class method like this..
B b=new AA();
It gives compile time error so cast it.
B b=(B) new AA();
However, I'm not sure why it's not working how I expect. Any thoughts?