Superclass/Subclass methods : <p>I have a situation</p>

<pre><code>public class Animal
{
   String noise;

  public String makeNoise()
  {
      return noise;
  }
}
</code></pre>

<p>Then there will be a subclass with the concrete definition of the noise.</p>

<pre><code>public class Dog extends Animal{
   String noise = "woof";
}
</code></pre>

<p>also</p>

<pre><code>public class Cat extends Animal{
   String noise = "meow";
}
</code></pre>

<p>What I want to do is</p>

<pre><code> Animal cat = new Cat();
 cat.makeNoise();  // This will be 'meow'
</code></pre>

<p>and </p>

<pre><code>Animal dog = new Dog();
dog.makeNoise();  // This will be 'woof'
</code></pre>

<p>Basically, I don't want to repeat the makeNoise() method when I create an animal. However, this will not work. (Noise is an empty string)</p>

<p>I could use a static object like </p>

<pre><code>static String NoiseDog = "woof"
static String NoiseCat = "meow"
</code></pre>

<p>but then again I have to write the makeNoise() method for each animal. Is there a better way to architect this?</p>
