Hi, I have been wondering about how implementation/extension works :

Let me give you an example and then ask you my question :

public abstract interface A_int {}
public abstract interface B_int {}

public class A implements A_int, B_int {}

public class B extends A implements A_int

okay so here's my question :

Does class B also implement interface B_int?
I think yes, but I wanna make sure.
Thank you

8 Years
Discussion Span
Last Post by hermann87

Yes, and No. A implements, and so, by default, those methods are "available" through the B Class, since B is an A, but B, it self, does not, technically, implement the other interface.


Does class B also implement interface B_int?

What does the compiler say? Code a test and compile it and let us know the results.

Edited by NormR1: n/a


First of all - every interface is by default abstract entity, so you shouldn't use special modifier (abstract keyword).

Second, saying in a structural way - yes - the class will be implements interface B_int, but not directly - it rather would extends A which must implements them after that all methods from interfaces became simple abstract methods.

So if you need to check fact of implementation in a case of reflection you need to go up in the inheritance tree or needs to use construction like this:

TargetInterface.class.isAssignable( TargetClass.class );
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.