title: Calling methods inside Constructor
body: <p>Below I am Having Two classes.Parent and Child. The Child class inherits from Parent class .In Parent class constructor I am calling print() method of Parent class.</p>
  
  <p>When I create Object for Child class in main() method the Parent class constructor runs and the Child class print() method is called instead of Parent class print() method.</p>
  
  <p>Q1. Why this Happens.</p>
  
  <p>Q2. Why the value of i is 0</p>
  
  <pre><code>public class Sample
  {
      public static void main(String[] args) 
      {
          Child objChild = new Child();
          objChild.print();
      }
  }
  
  class Parent
  {   
      void print()
      {
          System.out.println("i Value");
      }
  
      Parent()
      {
          print();
      }
  }    
  
  class Child extends Parent
  {
      int i = 45;
  
      void print()
      {
          System.out.println("i Value = "+i);
      }
  }
  </code></pre>
  
  <p>OP</p>
  
  <pre><code>i Value = 0
  i Value = 45
  </code></pre>