i have two classes in java as:
class A { int a=10; public void sayhello() { System.out.println(\"class A\"); } } class B extends A { int a=20; pub
B extends A and therefore B can be cast as A. However the reverse is not true. An instance of A cannot be cast as B.
If you are coming from the Javascript world you may be expecting this to work, but Java does not have "duck typing".