Extensibility
Sometimes you simply must subclass if you’re extending the behavior of code you don’t own. In the example above, it’s possible Button is part of a framework you’re using, and there’s no way you can modify or extend the source code to fit your needs.
In that case, subclass Button so you can add your custom subclass and use it with code that’s expecting an object of type Button. Using access control, discussed in detail in Chapter 19, “Access Control and Code Organization”, the author of a class can designate if any of the members of a class can be overridden or not.