I implemented this code:
class A {
//some code
}
class B extends A {
// some code
}
class C {
public static void main(String []args)
{
Because the A is a parent of B. B extends the functionality of the A but keeps the original functionality of A. So B can in fact be cast to A, but not vice versa.
What if B added a new method, let's say newMethodInB(). If you would try to call that method through variable B on the instance A (imagine that the cast worked) what would you expect? Well, you would definitely get an error because that method does not exist in A.