title: What's wrong with this example of Java property inheritance?
body: <h2>Inheritance.java</h2>
  
  <pre><code>public class InheritanceExample {
    static public void main(String[] args){
      Cat c = new Cat();
      System.out.println(c.speak());
  
      Dog d = new Dog();
      System.out.println(d.speak());
    }
  }
  </code></pre>
  
  <h2>Animal.java</h2>
  
  <pre><code>public class Animal {
    protected String sound;
    public String speak(){
      return sound;
    }
  }
  </code></pre>
  
  <h2>Cat.java</h2>
  
  <pre><code>public class Cat extends Animal {
    protected String sound = "meow";
  }
  </code></pre>
  
  <h2>Dog.java</h2>
  
  <pre><code>public class Dog extends Animal {
    protected String sound = "woof";
  }
  </code></pre>
  
  <hr>
  
  <h2>Output:</h2>
  
  <pre><code>null
  null
  </code></pre>
  
  <p>My animals cannot speak. So sad.</p>