With inheritance technology, you can easily add new method declarations for an interface or combine several interfaces into a new interface. In both cases, you end up with a new interface, as shown in the following example:
: Horrorshow.java
//Extending a interface with inheritance
interface Monster {
void menace ();
}
Interface Dangerousmonster extends Monster {
void Destroy ();
}
Interface Lethal {
void Kill ();
}
Class Dragonzilla implements Dangerousmonster {public
void Menace () {} public
void Destroy () {}
}
Interface Vampire
extends Dangerousmonster, lethal {
void Drinkblood ();
}
Class Horrorshow {
static void U (Monster b) {b.menace ();}
static void V (Dangerousmonster d) {
d.menace ();
D.destroy ();
}
public static void Main (string[] args) {
Dragonzilla if2 = new Dragonzilla ();
U (IF2);
V (IF2);
}
///:~
Dangerousmonster is a simple extension of the monster, which eventually generates a new interface. This was achieved in the Dragonzilla.
Vampire syntax is only available when inheriting interfaces. In general, we can only apply the extends (extended) keyword to a single class. However, since interfaces may be composed of multiple other interfaces, extends may reference multiple underlying interfaces when building a new interface. As you can see, the name of the interface is simply separated with commas.