As we have noted, Java does not allow you to inherit functionality from more than one parent. What if you need to create a class whose objects have behaviors that are associated with more than one "parent" class?
Java lets you extend one parent, so that your class will inherit all the behaviors of that class. You are also allowed to implement as many interfaces as you like. Interfaces specify behaviors but do not provide any implementations. Instead, any class that claims to implement an interface must provide code for each and every method specified in the interface.
Go to the API documentation and look up both the Button class and the Comparable interface. Then take a look at SortableButton.java.
A SortableButton is both a button (so it can be displayed in a container, can have an action associated, etc.) and it's Comparable (so it can be entered into many of the collections that maintain an ordering, such as a TreeSet).
When you've done that, a homework exercise is to Swingify the sets
(See next chapter and next exercise). Use
JFrames and JButtons, extend them, and arrange the inheritance and the
implementation of the interface.