Java Inheritance: Why super class variable is reffered
<p>I have a super class "Sam" and a sub-class "SubSam"</p>

<pre><code> public class Sam {

String msg;
String msg1;

Sam(String mm, String mm1) {
    msg = mm;
    msg1 = mm1;
}

@Override
public String toString() {
    return this.msg + "  " + this.msg1;
    }
}

class SubSam extends Sam {

String msg1="C";

public static void main(String[] args) throws Exception {
    SubSam obj = new SubSam();
    System.out.println(obj);
}

SubSam() {
    super("A", "B");
}
}
</code></pre>

<p>The output is:</p>

<pre><code>A  B
</code></pre>

<p>Why "toString()" is refering the instance fields of "Sam" instead of "SubSam".The output should be: A C</p>

<p>I am thinking over it for a long time now, but not geting?</p>
