aspose file tools*
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
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: 804
    
    1

Consider that:



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

Joined: Aug 03, 2008
Posts: 9313
    
  17

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: 804
    
    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: 18990
    
  40

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: 804
    
    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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: implementing multiple interfaces