title: Behavior of static blocks with Abstract classes
body: <p>Child Class:</p>
  
  <pre><code>public class ChildExtending extends ParentAbstract{
  
      public int childInt =111213;
      static{
          System.out.println("child static block executed");
      }
  
      public ChildExtending() {
          System.out.println("child const initialized");
      }
      public void MethodInChild(){
          System.out.println("MethodInChild called");
      }
      public static void main(String[] args){
          System.out.println(ParentAbstract.parentInt);
          System.out.println(ChildExtending.parentInt);
      }
  }
  </code></pre>
  
  <p>Abstract Class:</p>
  
  <pre><code>public abstract class ParentAbstract {
      public static int parentInt=80713; 
      static{
          System.out.println("parent static executed");
          parentInt=9;
      }
  
      public ParentAbstract(){
          System.out.println("parentAbstract initialized");
      }
  
      public void MethodInParent(){
          System.out.println("MethodInParent called");
      }
  
  }
  </code></pre>
  
  <p>Main class:</p>
  
  <pre><code>public class MainForCheck {
      public static void main(String[] args){
      /*  ParentAbstract pa = new ParentAbstract(){
  
          };*/
  
      /*  ChildExtending ce = new ChildExtending();
          ce.childInt=5;*/
  
          /*ChildExtending ce = new ChildExtending();
          ce.childInt=5;
          ce.MethodInChild();
          System.out.println("pareny int is"+ce.parentInt);*/
  
  
          ChildExtending ce = new ChildExtending();
          ce.MethodInParent();
  
      }
  }
  </code></pre>
  
  <p><strong>This gives me output:</strong></p>
  
  <p>parent static executed
  ]</p>
  
  <p>child static block executed</p>
  
  <p>parentAbstract initialized</p>
  
  <p>child const initialized</p>
  
  <p>MethodInParent called</p>
  
  <p><strong>Why is it not like this?</strong></p>
  
  <p>parent static executed</p>
  
  <p>parentAbstract initialized</p>
  
  <p>child static block executed</p>
  
  <p>child const initialized</p>
  
  <p>MethodInParent called</p>