YAIC (Yet Another Inheritance Confusion)
<p>I am sure this type of question is asked every day, but I am struggling with understanding why the mammal object is instantiated as a cat, and reports its name to be Morris.  However, unlike most cats, it does not have 9 lives.  If the object is not a cat, why does it report its name to be Morris?  </p>

<pre><code>class Mammal  {
    int temp;
    String name = "George";

    public Mammal() {
        temp = 98;
    }

    public String getName() {
        return name;
    }
}

class Cat extends Mammal {
    int lives;
    String name = "Morris";

    public Cat() {
        lives = 9;
    }

    public String getName() {
        return name;
    }
}

public class Inheritance {
    public static void main(String[] args) {
        Mammal mm = new Cat();
        System.out.println("Mam Temp:" + mm.temp);
        //System.out.println("Cat Lives:" + mm.lives);        &lt;-- error
        System.out.println("Mam Name:" + mm.getName());  
    }
}
</code></pre>
