Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How we get inheritence wih interfaces

 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !!
I know that I can have code like this to see multiple inherience in JAVA







I just want to know, what we are inheriting here...I know tthat interfaces ar very helpful in abstraction, but how does it buy multiple inheritence, what it does, we can't get without it..
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you will inherit new classes from MyClass.
 
Vijaypal Singh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The biggest reason as far as i can understand is a clear seperation of Two Features in two Interfaces.Now one of these interfaces may specify a protoype for soma utiity class then in that case you have yourfirst interface that you have to implement according to the need and the other for serving a generic utility.
the other reason is if you put every code in side one single class you lessen the chances of code reuse.
 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, David..
The subclasses of the MyClass will inherit the he two methods defined by the interfaces. That is fine.

But then again, I can inherit it even if I don't define the interfaces at all, and just make the two methods implemented in MyClass. I understand having interface makes the methods more manageable, separate....but is there any thing in terms of inheritence which can't be done without interfaces...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic