basic exercise in java
<p>I have two classes A and B as follows:</p>

<pre><code>public class A {
    private int salary = 0; 

    protected void calculate() {
        salary = 400;
    }

    protected A() {
        calculate();
    }   
}

public class B extends A {
    private int salary = 0; // (1)

    protected void calculate() {
        System.out.println("calculating salary...");
        salary = 700;   
    }

    public static void main(String[] args) {
        System.out.println(new B().salary); // (2)  
    }
}
</code></pre>

<p>Consider line (2): I don't understand why <code>new B().salary</code> is valid because the specifier of salary in line (1) is <code>private</code>. Could you help me explain it?</p>
