Forum Stats

  • 3,839,879 Users
  • 2,262,546 Discussions
  • 7,901,089 Comments

Discussions

How to achieve multiple inheritance java

a128d15a-720d-4ef4-b9ff-ceec9025acc1
edited Dec 1, 2015 12:05PM in New To Java

Hi Friend

I am having two class Ford and Car, both classes is having methods display. I can't touch this because both classes are third party class.

Say for Ex :

class Ford {

  public void meth(){

    System.out.println("Display Method Ford");

}

}

class Car{

public void meth(){

    System.out.println("Display Method Car");

}

}

Class FordCarImpl {

  public void meth(){

      // Need Ford Method

     //  Need Car Method

Can you please tell me How to call those two methods my implemented class instead of creating the object?

Regards

Sheik Dawood.K

Answers

  • Unknown
    edited Oct 13, 2015 3:14PM
    Can you please tell me How to call those two methods my implemented class instead of creating the object?

    Not possible - and it has NOTHING to do with 'inheritance', multiple or otherwise.

    Only methods declared 'static' can be called without first creating an instance of the object.

    Why don't you just tell us WHAT PROBLEM are you trying to solve?

    And why does the subject mention multiple inheritance (which Java doesn't support?

  • cesarHernandezGT
    cesarHernandezGT Member Posts: 42 Blue Ribbon
    edited Dec 1, 2015 12:05PM

    Java doesn't support Multiple Inheritance. If you need to make complex object based on others, you can work with defining and implementing interfaces. If you need to build complex object, go and take a look a design pattern, specially the creational ones.

    Hope that my answer helps to solve your question .

    Kind regards.!

This discussion has been closed.