Reputation: 57
public abstract class ClassA implements ClassB{
}
public class ClassC extends ClassA implements ClassB{
}
Since class "ClassC" is extending class "ClassA", does "ClassC" still has to implement "ClassB"? Or "ClassB" is automatically implemented for class "ClassC"?
Upvotes: 0
Views: 52
Reputation: 86764
Assuming ClassA
is not abstract
and fully implements ClassB
, then ClassC
inherits ClassA
's implementation and does not need to re-implement anything from ClassB
unless it wants to override the behavior.
It also does not need to specify implements ClassB
. The following example is valid:
public static interface I { }
public static class A implements I { }
public static class B extends A { }
public static void main(String[] args) {
I b = new B();
}
Upvotes: 1
Reputation: 25
You dont need do implement again it is already implemented by the Product Class, i've created an example to show you
I created the method just to show you how it would work
If you implement the interface into the super class all the childs will have the Interface methods! Hope it helps :)
Upvotes: 0