What is super-interface is java? what is the purpose of super-interface?
If you have
public interface Bar extends Foo
then Foo
would be the super-interface of Bar
. This declares that all instances of Bar
are also instances of Foo
and can be treated as such, so you could pass a Bar
instance wherever you needed to pass a Foo
, etc.
Here's an example:
public interface A {
void doSomething();
}
public interface B extends A {
void doSomethingElse();
}
In this example, A
is a superinterface of B
. It's like being a superclass. Any class implementing B
now also implements A
automatically, and must provide an implementation of both doSomething()
and doSomethingElse()
.
Basically, when an interface extends from other interface, it is forcing the class that implements it to implement methods in both interfaces.
If an extends clause is provided, then the interface being declared extends each of the other named interfaces and therefore inherits the member types, methods, and constants of each of the other named interfaces. These other named interfaces are the direct superinterfaces of the interface being declared. Any class that implements the declared interface is also considered to implement all the interfaces that this interface extends.
You can have method overriding also :)
http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html
Interfaces in Java can extend one another, so that the extending interface supports all the things provided by the parent and the things it provides itself. For example, a Set has unique operations, but also supports everything that a Collection does.
The interfaces from which you are extending are considered super-interfaces. Note that an interface can extend multiple interfaces and therefore has multiple super-interfaces.