This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes implementing multiple interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "implementing multiple interfaces" Watch "implementing multiple interfaces" New topic
Author

implementing multiple interfaces

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 808
    
    1

Consider that:



SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9405
    
  20

Is this a question?? You can't implement both interface A and B in one class...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 808
    
    1

OK, but a class can implement multpile interfaces. It's a particular example. Stay tuned!
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
Well,

This program won't compile. Because you cannot implement both interfaces in class C.
Compiler will be ambigious about method a(). Try to change the argument list in either A
or B, then will allow you to implement both the interfaces, as one method will be correctly
overloaded.

Best Regards,


Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 20057
    
  44

Lucas Smith wrote:OK, but a class can implement multpile interfaces. It's a particular example. Stay tuned!



Yes, Java supports implementing multiple interfaces --- but that doesn't mean that you can use the feature to get around overloading rules. You are not allowed to have to methods with the same signature and different return types in a class.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 808
    
    1

I see. I can notice some bugs in Java.


It is not perfect. The intention behind method a() from those interfaces can be different.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: implementing multiple interfaces
 
It's not a secret anymore!