Find out whether interfaces are inherited : Interface and Abstract Class « Language Basics « Java






Find out whether interfaces are inherited

Find out whether interfaces are inherited
/** Find out whether interfaces are inherited.
 * Start with Thread which implements Runnable.
 */
public class InterfaceInherit extends Thread {
  public static void main(String[] a) {
    new InterfaceInherit().start();
  }
  public void run() {
    if (this instanceof InterfaceInherit)
    System.out.println("This is InterfaceInherit");
    if (this instanceof Thread)
    System.out.println("This is Thread");
    if (this instanceof Runnable)
    System.out.println("This is Thread -- Interfaces ARE inherited!");
  }
}



           
       








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.Abstract classes and methodsAbstract classes and methods
11.Extending an interface with inheritance