Extend AND implement in the same class

Koen picture Koen · Nov 26, 2014 · Viewed 7.1k times · Source

How can I implement an interface AND extend a class to the same class?

This doesn't seem to work (the interface is not implemented at all):

public class StrongChecker extends BasicChecker implements Checker {

This doesn't work either (the interface is not implemented at all):

public class StrongChecker extends BasicChecker {

And this gives me an error:

public class StrongChecker implements Checker extends BasicChecker {

Thanks for your help !

Answer

Eran picture Eran · Nov 26, 2014

There is nothing wrong with:

public class StrongChecker extends BasicChecker implements Checker {

Of course, your StrongChecker class has to implement all the methods of Checker (or inherit implementations from BasicChecker), or the code won't compile.