Java inheritace
<p>I am learning Java . I got stuck in basic Inheritance property.</p>

<p>Can any one explain will be of great help.</p>

<pre><code>public class A{
  int x;
  protected void setX(){
    int x = 2;
  }
  protected int getX(){
    return x;
  }
}

public class B extends A{

 System.out.println(getX()); // ERRoR.
}
</code></pre>

<p>Error give me Null Pointer.</p>

<p><a href="http://xahlee.org/java-a-day/extend.html" rel="nofollow">chk this link</a> . i used this this link to understands inheritance.</p>
