let's have superclass of animal
, , subclass of dog
.
we can upcast saying:
animal = new dog();
we cannot downcast saying:
dog b = new animal();
so understand animal not have dog. but, why having animal "blueprint" in dog container throw exception? because dog inherits methods animal, when take animal , put dog container, know dog inherits/overrides methods animal has, why java not allow this?
thank you!
dog b = new animal(); b.woof();
animal has no interface/method called woof(). not know how behave dog, dogs know how behave animal.