Should I implement an interface directly or have the superclass do it?

Posted by c_maker on Programmers See other posts from Programmers or by c_maker
Published on 2012-12-19T02:12:19Z Indexed on 2012/12/19 5:12 UTC
Read the original article Hit count: 172

Filed under:
|
|

Is there a difference between

public class A extends AbstractB implements C
{...}

versus...

public class A extends AbstractB
{...}
AbstractB implements C
{...}

I understand that in both cases, class A will end up conforming to the interface. In the second case, AbstractB can provide implementation for interface methods in C. Is that the only difference?

If I do NOT want to provide an implementation for any of the interface methods in AbstractB, which style should I be using? Does using one or the other have some hidden 'documentation' purpose?

© Programmers or respective owner

Related posts about java

Related posts about interfaces