title: Static members in Java
body: <p>I've read Statics in Java are not inherited. I've a small program below which compiles and produces <code>2 2</code> as output when run. From the program it looks like k (a static variable) is being inherited !! What am I doing wrong?</p>
  
  <pre><code>class Super
  {
      int i =1;
      static int k = 2;
      public static void print()
      {
          System.out.println(k);
      }
  }
  class Sub extends Super
  {
      public void show()
      {
          // I was expecting compile error here. But it works !!
          System.out.println(" k : " + k);
      }
      public static void main(String []args)
      {
          Sub m =new Sub();
          m.show();
          print();
      }
  } 
  </code></pre>