File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Multiple inheritence with interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple inheritence with interface" Watch "Multiple inheritence with interface" New topic

Multiple inheritence with interface

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 142

In preceding code how to provide implementation of add() in Test class
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

raj chiru wrote:
In preceding code how to provide implementation of add() in Test class

implementation is nothing but writting the logic(coding) for a method


Eric Mission

Joined: Apr 22, 2009
Posts: 22
simple, you can't so, you don't. That isn't an issue when following the javabean convention...

to infinity and beyond
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
You have a collision. Collisions between interface methods can always be resolved providing the following three conditions apply:
  • 1: The methods have the same signature. (Otherwise it is overloading and not a collision at all).
  • 2: The methods have compatible intent (see below).
  • 3: The methods have the same return type. (You will have to check in the Java Language Specification for the exact details.)
  • You are violating no 3 here, and it will never compile.
    This is overloadingAnd this is incompatible intentObviously the WackyArithmetic#add method is only suitable for jokes, but I challenge you to implement both those interfaces in accordance with their specifications given.

    Have a look at these three add methods: note that the first is intentionally given a vague specification so both sub-interfaces can implement it differently, but still be compatible in intent. 1 2 3
    I agree. Here's the link:
    subject: Multiple inheritence with interface
    It's not a secret anymore!