Hi,
I'm trying to revise for a uni software engineering exam in a couple of weeks, and im having some problems understanding type substitution.
Here is a question from a past exam paper:Click
Now, I hate this exam because of the vagueness between answers, there are multiple correct ones and we have to pick the 'best' answer, in this case i think the best one is A, while D is correct it isn't a reason for 'good design'.
What i don't understand is how (in the case of D) a child class can be substituted for its parent class type, when by definition a child class implements additional functionality to its parent class. So how can you substitute a child type into a parent type which doesn't understand half of its functionality? Maybe im thinking about this incorrectly in which case i hope someone can point me towards the right direction. Is this what strong typing is?
Thanks for any help
Jack
I'm trying to revise for a uni software engineering exam in a couple of weeks, and im having some problems understanding type substitution.
Here is a question from a past exam paper:Click
Now, I hate this exam because of the vagueness between answers, there are multiple correct ones and we have to pick the 'best' answer, in this case i think the best one is A, while D is correct it isn't a reason for 'good design'.
What i don't understand is how (in the case of D) a child class can be substituted for its parent class type, when by definition a child class implements additional functionality to its parent class. So how can you substitute a child type into a parent type which doesn't understand half of its functionality? Maybe im thinking about this incorrectly in which case i hope someone can point me towards the right direction. Is this what strong typing is?

Thanks for any help
Jack