I don't know if this is a best practices or not. If I have a interface that extends another interface such as :

public interface A extends B{
    public void something();

and a concrete class that implements A such as:

public class MyClass implements A {
    public void something(){

    public void somethingFromB(){
        System.out.println("Hey, Scoobs!");

Should I be adding B to the concrete class to identify the other interface?


A extends B means "A is a B". By implementing A, MyClass says "I'm a A, and therefore I'm B".

So, given the Java semantic, it's perfectly right to only (directly) implement the specialized interface. It's clear, and it avoids redundancy.

The only case where a redefinition could be interesting is when you use an interface as a marker (which is probably not such a good idea). It's simpler to get the interfaces directly implemented by a class rather than all the interfaces, including the inherited and extended ones.

Personally, I never 'redeclare' an implementation.

  • Thanks, this makes sense, Clarity it what I am going for. – Shane Andrie Nov 17 '15 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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