Forums Java Help Why Java doesn’t support multiple inheritance

This topic contains 1 reply, has 2 voices, and was last updated by  nammy 6 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15512

    kingsly
    Participant

    Why Java doesn’t support multiple inheritance?

    #15513

    nammy
    Participant

    Answer: Java doesn’t support multiple inheritances in classes because of “Diamond Problem”. For example a class A has foo() method and then B and C derived from A and has their own foo() implementation and now class D derive from B and C using multiple inheritance and if we refer just foo() compiler will not be able to decide which foo() it should invoke. Problems like this is also called Diamond problem because structure on this inheritance scenario is similar to 4 edge diamond.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.