Multi Super Interfaces : Interface and Abstract Class « Language Basics « Java






Multi Super Interfaces

public class MultiSuperInterfaces {
  public interface Marker extends java.io.Serializable, java.rmi.Remote,
      java.lang.Runnable {
  }

  public class Marked implements Marker {
    public void run() {
      // needed for Runnable
    }
  }

  public static void main(String[] args) {
    new MultiSuperInterfaces().print();
  }

  void print() {
    Object o = new Marked();
    if (o instanceof java.io.Serializable) {
      System.out.println("Is Serializable");
    }
    if (o instanceof java.rmi.Remote) {
      System.out.println("Is Remote");
    }
    if (o instanceof java.lang.Runnable) {
      System.out.println("Is Runnable");
    }
  }
}
           
       








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.This shows that a class implementing an interface need not
9.Find out whether interfaces are inheritedFind out whether interfaces are inherited
10.Abstract classes and methodsAbstract classes and methods
11.Extending an interface with inheritance