• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Multiple Interface Inheritance / Interface Inheritance

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inteface A

Interface B extends A ---> Is it Interface Inheritance ?

Class C implements B --> Is it Multiple Interface Inheritance ?

Java does not support Interface Inheritace.

 
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an interface is a contract - nothing else. When you have

Interface A {}

you are saying "here are the rules for what it means to implement the 'A' interface.

When you say "implements A", you are saying "This class/abstract class will implement everything required by the A interface"

so,

interface B extends A

is just saying "here are the rules for implementing the B interface, which by the way, must also implement the A interface."

and "Class C implements B" is just saying "I promise that the C class will implement everything required by the B interface (which just so happens to also require implementation of the A interface".

it's not really inheritance at all.

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:

interface B implements A



Just a nitpick, but interfaces extend other interfaces, not implement.
 
fred rosenberger
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multiple inheritance means: a class that extends two classes.

But if you make a "chain": B extends A, and C extends B - then that is not multiple inheritance.

Java doesn't have multiple inheritance because it causes some hard problems like the diamond problem and because it's not an essential feature. A large part of Java was designed to look like C++, but with the hard parts left out. This is an example of a C++ feature that was left out of Java.

See http://en.wikipedia.org/wiki/Multiple_inheritance
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic