tags:

views:

60

answers:

2

for example:

SortedSet EXTENDS Set
NavigableSet EXTENDS SortedSet

is the benefit finally gained at the bottom most level (one that actually implements)?. In above case it would be TreeSet

Would it be fair to say that if some class is EXTENDING an interface then that class SHOULD/MUST be an interface?

+6  A: 

Yes, only interfaces can extend other interfaces. Classes implement interfaces, they don't extend them.

The purpose of an interface which extends another interface is to show that SortedSet is an extension of the Set interface. SortedSet is a Set, with additional operations.

matt b
And as such, you can do something like `Set someSet = new TreeSet();` ignoring that it's a `SortedSet` in the process.
R. Bemrose
+1  A: 

is the benefit finally gained at the bottom most level (one that actually implements)?

The benefit is the same as for interfaces in general: specifying a contract. Interface hierarchies basically just save you some typing and prevent unintentional mismatches: SortedSet doesn't have to repeat the methods in Set, and there is no risk to end up with the same functionality in slightly different methods.

Would it be fair to say that if some class is EXTENDING an interface then that class SHOULD/MUST be an interface?

MUST would be correct. Classes cannot extend interfaces, only implement them.

Michael Borgwardt