Why the following code doesnt show any conflict since both, method1 in iface1 and aclass1 have the same name and must be implemented by class test1a. It seems that test1a is implementing the aclass1 method and not the iface1, why?
Thanks in advance,
Post by:Rob Spoor
Welcome to the Ranch!
Your class is implementing both. The abstract method / interface method merely indicate that there should be a method called method1 that takes no parameters and returns void. And it does just that.
Post by:Campbell Ritchie
There is only one way you could have a conflict: if the two methods did not have compatible intentions. I have amended your code to introduce such an incompatibility By the way: please use spaces, not tabs, for indenting.
Post by:fred rosenberger
Note that even in Campbell's example, you can write code that compiles and runs - it just may not work the way everyone hopes.
When you implement an interface, all you are saying is "My class will have a definition/implementation for these methods".
When you extend an abstract class with a concrete class, you have to implement the abstract methods.
Note that by writing the method once, you have fulfilled your obligation to both.
If your mom says "You have to clean your room today", and your dad says "You have to clean your room today", as long as you clean it once, you have fulfilled both obligations.