import java.io.*; public class ErrorTest { void foo() throws IOException { throw new RuntimeException(); } public static void main(String[] args) { ErrorTest err = new ErrorTest(); try { err.foo(); } catch (IOException e) { System.out.println("Caught exception"); } } }