This shows that a class implementing an interface need not : Interface and Abstract Class « Language Basics « Java






This shows that a class implementing an interface need not


import java.io.*;

/** This shows that a class implementing an interface need not
 * declare all the Throws that are declared in the interface.
 */
public class InterfaceWithoutAllThrows {
  interface bar {
    public void foo() throws IOException;
  }
  class baz implements bar {
    public void foo() {
      System.out.println("This is foo-lish");
    }
  }
  public static void main(String[] argv) {
    new InterfaceWithoutAllThrows().new baz().foo();
  }
}


           
       








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.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