This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple inheritence with interface" Watch "Multiple inheritence with interface" New topic
Author

Multiple inheritence with interface

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
Hi...



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

example

Eric Mission
Greenhorn

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
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
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
     
     
    subject: Multiple inheritence with interface
     
    Similar Threads
    Dan's Q: Anonymous classes
    Interface vs AbstractClass
    Interfaces
    problem with deadly diamond of death
    Generics problem