Java Downcasting of extending class : <p>Why this code is not working? When i casting, I get ClassCastExeption
Exception in thread "main" java.lang.ClassCastException: A cannot be cast to B
    at HelloWorld.main</p>

<pre><code>public class HelloWorld
{
 public static void main(String[] args)
  {
    B b1 = (B)new A();
    b1.a();
   }
}

public class A
{
  public void a (){
  System.out.println("A.a");
  }
  public void b (){
  System.out.println("A.b");
  }
}

public class B extends A{ 
}
</code></pre>
