• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How we get inheritence wih interfaces

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you will inherit new classes from MyClass.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic