为什么下列程序中,当执行完 A a=new B();B b=(B)a;后,a指向什么?是哪个类的对象引用?为什么a.g();出错?
class A
{
A(){System.out.println("A()");}
void f(){System.out.println("A.f()");}
}class B extends A
{
void f(){System.out.println("B.f()");}
void g(){System.out.println("B.g()");}

public static void main(String[] aa)
{
A a=new B();
B b=(B)a;
System.out.println( a instanceof B);//true
a.f();
b.f();
a.g();//为什么出错?a此是指向什么?
}
}