why we can't override the variables in java
<p>why we can't override the variables in java , It hides variable </p>

<pre><code>class A {
    int a = 4;
    public void test(){
        System.out.println("Test method of A" );
    }
} 

class B extends A {
    int a = 5;
    public void test(){
        System.out.println("Test method of B" );
    }
    public static void main(String s[]){
        A a= new B();
        System.out.println("Value of a : " a.a );
        System.out.println("Method result " a.test() );
    }
} 
</code></pre>

<p>Output ::</p>

<pre><code>Value of a : 4
Mthod result :Test method of B
</code></pre>

<p>As the B's class test method get called but variable was accessed from super class reference</p>
