title: Java Inheritance and method overriding program
body: <p>I have the following exercise regarding inheritance and methods overriding, and the question is why the 'System.out.println(f1)' in the 'initialize()' method in the parent class is called with param '0', and what is needed to do to for it will be called with param '6'. Please help me understand it. Thanks in advance.</p>
  
  <pre><code>public class Solution {
  public static void main(String[] args) {
      new B(6);
  }
  
  public static class A {
      private int f1 = 7;
  
      public A(int f1) {
          this.f1 = f1;
          initialize();
      }
  
      protected void initialize() {
          System.out.println(f1);
      }
  }
  
  public static class B extends A {
      protected int f1 = 3;
  
      public B(int f1) {
          super(f1);
          this.f1 += f1;
          initialize();
      }
  
      protected void initialize() {
          System.out.println(f1);
      }
  }
  </code></pre>
  
  <p>}</p>