while doing upcasting how the below code will execute : <p>When I execute it method portion is overriding nd giving subclass statement as o/p but variable is giving superclass value?also can u explain memory allocation for this?</p>

<pre><code>public class demo {

    public static void main(String[] args) {
            aaa bb=new b();
            System.out.println(bb.a);
                int c=bb.eat();
                System.out.println(c);
    }
}
class aaa{
    int a=30;
    int eat()
    {int x=60;
        System.out.println("CHEWING");
        return x;
    }
}
class b extends aaa{

    int a=23;
    int eat()
    {
//super.eat();
        int x=70;
        System.out.println("EaTING");
        return x;
    }
}
</code></pre>
