title: Downcasting/Upcasting error at compile time & runtime?
body: <p>Please check the below program.  </p>
  
  <p>I have doubt when compiler will issue casting exception at compiler level and when it will be at <code>runtime</code>?  </p>
  
  <p>Like in below program, expression </p>
  
  <p>I assumed <code>(Redwood) new Tree()</code> should have failed at compiler time as Tree is not Redwood. But it is not failing in <code>compile time</code>, as expected it failed during <code>runtime</code>!!!</p>
  
  <pre><code>public class Redwood extends Tree {
       public static void main(String[] args) {
           new Redwood().go();
       }
       void go() {
           go2(new Tree(), new Redwood());
           go2((Redwood) new Tree(), new Redwood());
       }
       void go2(Tree t1, Redwood r1) {
           Redwood r2 = (Redwood)t1;
           Tree t2 = (Tree)r1;
       }
   }
   class Tree { }
  </code></pre>