This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple inheritence with interface

 
Raj chiru
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...



In preceding code how to provide implementation of add() in Test class
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simple, you can't so, you don't. That isn't an issue when following the javabean convention...

 
Campbell Ritchie
Sheriff
Pie
Posts: 47261
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic