Abstract class extends concrete class

This becomes useful if I have a set of classes that I want a default implementation of test() for (so they can extend from Foo), and a subset of those classes that I want to force to provide their own implementation (in which case making it abstract in the subclass would enforce this.)

Of course, the alternative way in this example would be to declare test() abstract in the top level class rather than in the subclass, and that’s what you’d usually do – but there are cases where satisfying the is-a relationship of inheritance means that it occasionally makes more sense from a design perspective doing it this way around. It’s rare, but you do sometimes see it.

As an aside, though a special case, remember that all classes implicitly extend Object unless otherwise specified. So if you include this case, abstract classes extending concrete classes isn’t so unusual after all!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)