IntelliJ Java IDE
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: 747

Consider that:



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

Joined: Aug 03, 2008
Posts: 9090

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

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

Joined: Oct 13, 2009
Posts: 767
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: 14606

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

I see. I can notice some bugs in Java.


It is not perfect. The intention behind method a() from those interfaces can be different.
 
IntelliJ Java IDE
 
subject: implementing multiple interfaces
 
Threads others viewed
can interface have abstract methods
interface within class or interface
WebService End Point Interface:
Urgent!!!!!!!! private/protected interface
Upgrading our app from JDK1.4 to JDK1.5
MyEclipse, The Clear Choice