I understand multiple inheritance and interface to an extent. Is it possible to use Multiple inheritance to achieve my requirement?
I have classes A,B,C,D which implements interface InterA, InterB, InterC, InterD respectively. I want a class ABCD which should have all the methods of A, B, C, D. Then I want the declared methods in InterA, InterB, InterC, InterD available at class ABCD.
I have implementations of methods in InterA, InterB, InterC, InterD already defined in classes A,B,C,D, which I don’t want to define again in class ABCD. How can I do this in Java?
Since there is no multiple inheritance in Java you have to resort to aggregation:
That way you just have to create some instances of A, B, C and D and pass them at the construction of ABCD. Then ABCD just have to call their methods.
By doing that you will reuse the implementations of A, B, C and D.