Is there a difference between

public class B implements C
public class A extends B implements C    


public class B implements C
public class A extends B

Is it just redundant implementation? Or there are advantage to do that?


Asking this question, because I saw it in java.util package e.g.

public class HashMap<K,V> extends AbstractMap<K,V>
    implements Map<K,V>

public abstract class AbstractMap<K,V> implements Map<K,V>
  • 5
    It is redundant but harmless, and completely up to your discretion.
    – user22815
    Commented Apr 21, 2016 at 21:15
  • It's all about inheritance. Interface benefits nothing in this case.
    – Minh Tri
    Commented Apr 22, 2016 at 4:34

3 Answers 3


For most intents and purposes you don't need to implement an interface on the derived class. However there is a difference between the two if you do reflection.


public class InterfaceTest {

    static interface I {
        public void doSomething();

    static class A implements I {
        public void doSomething() {

    static class B extends A {   

    public static void main(String[] args) {

        for (Class i:A.class.getInterfaces()) {


        for (Class i:B.class.getInterfaces()) {

        B b=new B();

        System.out.println(b instanceof I);

This outputs:


So while b is an instance of I of course, B.class.getInterfaces() does not return any. You have to traverse the class hierarchy to find all interfaces that are implemented.

An example where this is relevant is using JPA AttributeConverters with Hibernate. An attribute converter has to implement the JPA AttributeConverter interface directly at this point, implementing it on a base class does not work. While this is reported as a bug in Hibernate, it still showcases that there are slight differences depending where you implement the interface and the use case.


They effectively do the same thing, so generally you'd only need to implement the interface on the base class.

However, if the derived class would need to implement this interface, independent of the fact the base class also implements it, then it would not hurt to also implement it in the derived class. In other words, if the base class were to no longer implement this interface, would the derived class still need to? You might want to comment why it is also implemented in the derived class.

I'm struggling to come up with even a contrived example of where this might apply, though. Sorry no realistic examples come to mind.

Related: If you are using Java and these are "Marker Interfaces", you can instead use "Marker Annotations" which are not inherited: http://www.artima.com/weblogs/viewpost.jsp?thread=98061


If the parent class and the derived class implement the same interface then maybe there is a situation where the derived class might want to code an interface method differently to how it is coded in the parent class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.