title: Accessability of private fields in Java
body: <p>I know that if a instance variable of a class is made <code>private</code> then it is not accessed directly by the object.</p>
  
  <p>But in the following code,something as such is happening,and the code is running fine!</p>
  
  <p>How is <code>b</code> able to directly access length,breadth and height?</p>
  
  <pre><code>public class Box {
      private int length,breadth,height;
      Box(int a,int b,int c){
          length=a;
          breadth=b;
          height=c;
      }
      Box(Box b){
          length=b.length;            //These lines!
          breadth=b.breadth;
          height=b.height;
      }
      int volume(){
          return length*breadth*height;
      }
  }
  
  public class BoxWeight extends Box{
      public int weight;
      BoxWeight(int a,int b,int c,int d){
          super(a,b,c);
          weight=d;
      }
      BoxWeight(BoxWeight b){
          super(b);
          weight=b.weight;
      }
  }
  class apples
  {
      public static void main(String[] args)
      {   
          BoxWeight mybox1=new BoxWeight(10,20,30,40);
          BoxWeight clone=new BoxWeight(mybox1);
          System.out.println(mybox1.volume()+"...."+mybox1.weight);
          System.out.println(clone.volume()+"...."+clone.weight);
      }
  }
  </code></pre>