title: Instance variable, when re-initialised in sub class' initialization block, is overridden like instance method, which it should not
body: <p>I have just started learning Java.I understand</p>
  <ol>
  <li>Unlike instance method, instance variable can not  be overridden, and are not dynamically picked by JVM at run time when accessed polymorphically.</li>
  <li>flow of execution : static block, super constructor, initialization block and      then constructor.</li>
  </ol>
  <p>But I am stuck at one code, where I have polymorphically invoked a instance variable but its showing overridden value (which it should not show). The instance variable is overridden inside sub class' init block.</p>
  <pre><code>package package1;
  
  public class Other {
      
      public static void main(String [] args){
              Parent referToChild = new Child();
              Parent referToChildTwo = new ChildTwo();
              System.out.println(&quot;age as referred by referToChild reference variable is:&quot; + referToChild.age);// prints 35 (doubt 1)
              System.out.println(&quot;age as referred by referToChildTwo reference variable is:&quot; + referToChildTwo.age);// prints 50 (doubt 2)
              System.out.println(&quot;money as referred by Other reference variable is:&quot; + referToChild.money);
              //System.out.println(&quot;Other reference variable is:&quot; + othObj.age);
      }
  }
  
  class Child extends Parent{
      // init block 
      {
          age = 35;
      }
  }
  
  class ChildTwo extends Parent{
      public int age;
      {
          age = 40;
      }
  }
  
  class Parent{
       public int age = 50;
       public int money = 100;
  }
  </code></pre>
  <p>The answer I get is:</p>
  <blockquote>
  <p>35</p>
  <p>50</p>
  <p>100</p>
  </blockquote>
  <p>so my doubts are:</p>
  <p>doubt 1 :Why is it showing &quot;35&quot;, it should display super class' variable's value which is 50.</p>
  <p>doubt 2 : When it is displaying sub class' variable's value for last case, then why not for this case.</p>