What is a multiple inheritance?

What is a multiple inheritance?

What is a multiple inheritance?

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on recent service-oriented architecture (SOA) and SOA-related topics such as integration, governance, Web services, Cloud and more.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSOA.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSOA.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

Multiple inheritance is an object-oriented term indicating the ability of a child class to use or "inherit" functionality of multiple parent classes.

In the C++ programming language, this concept is expressed in class "AChild", as follows:


class Parent1 {...};

class Parent2 {...};

class AChild : public Parent1, public Parent2 {...};

The Java programming language does not support the concept of multiple inheritance of classes, but it does support the concept of multiple interface inheritance.

Let's take a look at a simple example of multiple interface inheritance using the Java programming language.

First, we define the first parent interface:


public interface Parent1

{

public void sayHello();

}

Now, we define the second parent interface:


public interface Parent2

{

public void sayGoodbye();

}

Now, we define a child interface which inherits from both parent interface, using the "extends" keyword:


public interface AChild extends Parent1, Parent2

{

}

With these definitions in place, a class that implements the AChild interface will be required to implement the sayHello method and the sayGoodbye method.


This was first published in July 2004