Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:31:53+00:00 2026-06-05T01:31:53+00:00

I understand multiple inheritance and interface to an extent. Is it possible to use

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:31:54+00:00Added an answer on June 5, 2026 at 1:31 am

    Since there is no multiple inheritance in Java you have to resort to aggregation:

    class ABCD implements InterA, InterB, InterC, InterD
    {
       A implA;
       B implB;
       C implC;
       D implD;
    
       ABCD(A pimplA, B pimplB, C pimplC, D pimplD)
       {
         implA = pimplA;
         implB = pimplB;
         implC = pimplC;
         implD = pimplD;
      }
    
    
      // @overidde methods from InterA as return implA ->method();
      // @overidde methods from InterB as return implB ->method();
      // @overidde methods from InterC as return implC ->method();
      // @overidde methods from InterD as return implD ->method();
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

  I understand that elements can have multiple classes: .rfrsh-btn { background-image:url(../../upload/rfrsh_nb_grey.png); ... }
I understand that multiple inheritance 1 is simply not supported in PHP, and while
I'm trying to understand how cake implements its multiple JVM approach. At a high
I understand that C# does not support multiple inheritance, and that the solution is
I understand the need for virtual inheritance when using multiple inheritance -- it solves
I do not quite understand the benefit of multiple independent virtual address, which point
I understand the concept of multiple inheritance though i am trying to access the
From a quick Google search and a the wikipedia article on Multiple Inheritance, which
I have a series of classes A , B , ... which have many
I am trying to understand how multiple calls of car and cdr work together.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.