February 17th, 2016, 6:23 pm
It's a stupid question, but your job is to make it into something that can be answered as though it made sense.Was this one of the dipshit questions that Resource Solutions/Robert Walter ask ?A good interviewer is largely uninterested in whether the answer is right, but the quality of the thinking that led you there. So when asked questions like this show how you decide what to do.Firstly of course, any class can inherit from any other, circle can inherit from potato, the question is does it make for better code ?The first part of an answer to that they clearly would have a base class in common, since most methods and properties you'd want are the same.You might want to talk about an abstract base class 'Shape'. This is a good way to gain the initiative in the interview. If you demonstrate that you know about abstract bases, you are talking in your comfort zone and will sound smarter. This is better than them asking about ABCs (or whatever) because they might ask something you don't know, or you my misunderstand the question (we've all done that), or indeed because you seem to have been interviewed by Resource Solutions, you may get a bad question and they may not understand your answer.One kind of IS-A relationship is that you implement one class using another, which applies to your correct point that a circle IS-A ellipse.There are cases where you'd want a circle to be treated differently, a good interviewer would be interested in your knowledge of them. Some graphics hardware can draw circles faster than ellipses and in some types of manufacturing process perfect circles are deprecated because they are harder to get out of the mould. In the case of a CAD package implementing circles it may post process the object you've designed to make it the circle just non-circular enough. The reason I include non-quant examples is that I'm too stupid to give a quant one (I'm just some headhunter) and part of class design is to think "how would this be used by other people ?"Another type of IS-A is specialisation, so a circle could be an ellipse where you chose to hide the eccentricity.In writing a drawing package, you'd want to allow the user to change radius, but not bug them with a superfluous control for eccentricity.