title: In what order do static blocks and initialization blocks execute when using inheritance?
body: <p>I have two classes Parent and Child</p>
  
  <pre><code>public class Parent {    
      public Parent() {
          System.out.println("Parent Constructor");
      }    
      static {
          System.out.println("Parent static block");    
      }    
      {
          System.out.println("Parent initialisation  block");
      }
  }
  
  public class Child extends Parent {    
      {
          System.out.println("Child initialisation block");
      }
      static {
          System.out.println("Child static block");
      }
  
      public Child() {
          System.out.println("Child Constructor");
      }    
      public static void main(String[] args) {
          new Child();    
      }
  }
  </code></pre>
  
  <p>The output of the above code will be</p>
  
  <pre><code>Parent static block
  Child static block
  Parent initialization  block
  Parent Constructor
  Child initialization block
  Child Constructor
  </code></pre>
  
  <p>Why does Java execute the code in that order?  What are the rules that determine the execution order?</p>