title: Java: initialization of private variables in superclass
body: <p>Will the private variables initialized outside the constructor in the superclass be correctly inherited in the subclass?</p>
  
  <p>For instance, in the following codes, will the private instance variable x be correctly inherited in the subclass? I know that x and y can be accessed in the Square subclass only with the 2 public getters defined in Rectangle. However, if x is initialized outside the constructor, will the subclass still successfully inherit x?</p>
  
  <pre><code>public class Rectangle
  {
      private int x = 0;
      private int y;
      protected double height;
      protected double length;
  
      public Rectangle(double length, double height)
      {
          this.height = height;
          this.length = length;
          y = 0;
      }
  
      public int getx()
      {
          return x;
      }
  
      public int gety()
      {
          return y;
      }
  }
  
  
  public class Square extends Rectangle
  {
      public Square(double side)
      {
          super(side, side);
      }
  }
  </code></pre>