Why can't a reference, which is assigned to a child class, access the child class's members
<pre><code>class pract1 {

    String s="s1";
    public String getS()
    { 
        return s; 
    }
 } 
class pract  extends pract1{
    String a="s2";
    public String getS()    { 
        return a;
    } 
    public static void main(String[] args) { 
        pract1 parent= new pract1();
        pract child= new pract();
        parent=child;
        System.out.println(parent.a); // syntax error it should be (parent.s);
        System.out.println(parent.getS());
    }
 }
</code></pre>

<p>Here i am assigning <code>child</code> to <code>parent</code>. Using the <code>parent</code> reference, I should be able to access the <code>a</code> field. However, that is giving a compile error. Why?</p>
