File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes implementing multiple interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "implementing multiple interfaces" Watch "implementing multiple interfaces" New topic
Author

implementing multiple interfaces

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 717

Consider that:



SCJP6, SCWCD5
Hunting for OCE:EJBD6...
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9023

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


Javaranch SCJP FAQ | SCWCD Links
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 717

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

Joined: Oct 13, 2009
Posts: 735
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/Beenish,
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: 13413

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: 717

I see. I can notice some bugs in Java.


It is not perfect. The intention behind method a() from those interfaces can be different.
 
 
subject: implementing multiple interfaces
 
MyEclipse, The Clear Choice