Class AbstractAction
implements interface Action
, but in Action
, there's a method actionPerformed(ActionEvent e)
which inherits from interface ActionListener
I know that the class implements an interface must supply all the implementations of methods in that interface
But I found that there's no implementation of actionPerformed(ActionEvent e)
in AbstractAction
, why ?
AbstractAction is an abstract class so it doesn't have to implement all of the methods on the interface. Abstract classes can't be instantiated so they can't be used without creating a subclass of it. Only concrete classes (ie non-abstract) have to provide an implementation of all methods of an interface. If you subclass AbstractAction your subclass will have to implement actionPerformed() or it will have to be abstract too.
Now those are the rules, but it doesn't make sense for AbstractAction to implement actionPerformed() because it couldn't possibly provide a useful implementation. Every subclass would have to override it's definition which makes it a good candidate for being marked abstract.