wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Extend an Interface (Not implement)? 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 "Extend an Interface (Not implement)?" Watch "Extend an Interface (Not implement)?" New topic
Author

Extend an Interface (Not implement)?

Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
I noticed in Java 6 API that the interface "Set" extends another interface "Collection".

I just thought you can't extend an interface but should be IMPLEMENTED ONLY.

Can anyone clarify this java rule?

Thanks a lot!


SCJP with 98% by...
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

Dear Erap Estrada,

java.util.Set is also an interface and an interface can extends another interface.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Of course, the Interface can extends the other interface, but we can only describe methods in each interface (Superclass interface and Subclass interface)..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Leonardo Carreira wrote:Of course, the Interface can extends the other interface, but we can only describe methods in each interface (Superclass interface and Subclass interface)..


we don't describe methods in an interface but only declare them.


SCJP 1.6 96%
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Thanks Neha, yes, its what i mean, i was wrong to use "describe" word..
sorry, perhaps it because my English language inadequacy..

Thanks..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Think about it for a moment. Does the second interface really implement the methods of the first? Can you instantiate the second interface?

Of course not. So the second interface doesn't implement the first, rather it extends it, but remains abstract. So it makes perfect sense that the second interface extends the first.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Extend an Interface (Not implement)?