スーパークラスの参照変数でサブクラスのオブジェクトを指すことができるのに、スーパークラスのその参照変数でサブクラスのメソッドにアクセスできないのはなぜですか..
たとえば。次のコードはエラーを出します..
class Parent
{
int a;
}
class Child extends Parent
{
void func()
{
System.out.println("abc");
}
public static void main(String s[])
{
Parent a=new Child();
a.func();
}
}