File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How we get inheritence wih interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How we get inheritence wih interfaces" Watch "How we get inheritence wih interfaces" New topic
Author

How we get inheritence wih interfaces

Mishra Anshu
Ranch Hand

Joined: Sep 16, 2003
Posts: 224
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..


"Ignorance is bliss"
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
If you will inherit new classes from MyClass.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Vijaypal Singh
Ranch Hand

Joined: May 25, 2004
Posts: 31
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.


---------------------------------<br />S.C.J.P 1.4(86%),S.C.W.C.D 1.4(88%)<br /> <br />God Must love crazy people...<br />He Makes so many of them.
Mishra Anshu
Ranch Hand

Joined: Sep 16, 2003
Posts: 224
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How we get inheritence wih interfaces