I’m preparing to interview and think that would be good if my answer for the question like “Explain inheritance in java with an example” will be real implementation from core java classes.
There are many examples like Animals hierarchic or Shape but I think it would be more wisdom represent real situation and try answer for question – why this implementation good for this situation.
With that You show that you have good knowledge not just inheritance but and core Java :)))
So what do you think about that??
Addition:
Good another article: What can be the bad example of inheritance in Java?
But in this article question is opposite to my.
The collections framework. It’s good because it contains several kinds of inheritance:
ListextendsCollection, an example of interface inheritanceAbstractListimplementsList, which is implementation rather than inheritance, but is a related ideaArrayListextendsAbstractList, an example of class inheritance for implementation reuseWhat i can’t find an example of is class inheritance for the purpose of defining a subtype relationship. However, if you move sideways a little, the java.util package also contains:
GregorianCalendarextendsCalendar