Extending an interface with inheritance : Interface and Abstract Class « Language Basics « Java

Extending an interface with inheritance

// : c08:HorrorShow.java
// Extending an interface with inheritance.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

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 VeryBadVampire implements Vampire {
  public void menace() {

  public void destroy() {

  public void kill() {

  public void drinkBlood() {

public class HorrorShow {
  static void u(Monster b) {

  static void v(DangerousMonster d) {

  static void w(Lethal l) {

  public static void main(String[] args) {
    DangerousMonster barney = new DragonZilla();
    Vampire vlad = new VeryBadVampire();
} ///:~


Related examples in the same category

1.Holds a sequence of ObjectsHolds a sequence of Objects
2.Initializing interface fields with non-constant initializers
3.Two ways that a class can implement multiple interfaces
4.Interface Collision
5.Multiple interfaces
6.Interface Usage ExampleInterface Usage Example
7.Implement multiple interfaces
8.Multi Super Interfaces
9.This shows that a class implementing an interface need not
10.Find out whether interfaces are inheritedFind out whether interfaces are inherited
11.Abstract classes and methodsAbstract classes and methods