I implemented this code:
class A { //some code } class B extends A { // some code } class C { public static void main(String []args) {
I'm not sure about the compile part, but I can explain the runtime error.
B extends A, which means that every object of class B, is also an object of type A. The other way around is not true.
Compare A with 'Mammal', and B with 'Cow'. A Cow is always a Mammal, but not every Mammal is a Cow.