posted 9 years ago
Here relation between Animal and Horse is IS-A relation. Animal is super type and Horse is sub type. so All Horse can be animals but all animals can't be Horse Ex. It can be cat, dog etc.
So it is an assignment conversion where widening conversion is safe but narrowing conversions is not recommended as it's not safe. When you say Animal a, b ; These reference variables points to a type of Animal which has it's instance variable method called eat() but it doesn't have buck method which Horse has so when you try to call method buck, using Animal reference variable which has no buck method as part of Animal type, it gives above error.