title: explicit casting from super class to subclass
body: <pre><code>public class Animal {
      public void eat() {}
  }
  
  public class Dog extends Animal {
      public void eat() {}
  
      public void main(String[] args) {
          Animal animal = new Animal();
          Dog dog = (Dog) animal;
      }
  }
  </code></pre>
  
  <p>The assignment <code>Dog dog = (Dog) animal;</code> does not generate a compilation error, but at runtime it generates a <code>ClassCastException</code>. Why can't the compiler detect this error?</p>