ujwwala tem wrote:
I know the concept of overriding from super class but still I am not clear as why there is a need for overriding ,cann't we write the complete functionality in subclass only,
ujwwala tem wrote:
So wht I understood is a overriding is based on he inheritance and polymorphysm so it is inappropriate to just define the method in subclass only instead we can override it a we want,
So, you started this topic saying that overriding doesn't serve a purpose (why there is a need at all)? And now you are saying that
you should always override (as it is inappropriate otherwise)? Which do you think is correct?
If I had to speculate on what the interviewer was thinking, I would say that he wanted your opinion, and the ability to back up those opinions. And quite frankly, if you answered with either one of those two options, it would probably come off badly. You need to understand what is inheritance (and polymorphism); why it is useful, and why it is not. In other words, the answer to this question should have been your view of the subject, and lead it to examples of your works; and discuss why you thought inheritance was appropriate in one case and not the other.
Henry