public class UjiInstanceOf {
    static void periksa(Throwable kegagalan) {
        System.out.println(kegagalan.getClass().getSimpleName()
                + " -> RuntimeException: " + (kegagalan instanceof RuntimeException)
                + " | Exception: " + (kegagalan instanceof Exception)
                + " | Error: " + (kegagalan instanceof Error)
                + " | Throwable: " + (kegagalan instanceof Throwable));
    }

    public static void main(String[] args) {
        periksa(new NumberFormatException("bukan angka"));
        periksa(new java.io.IOException("berkas tidak terbaca"));
        periksa(new InterruptedException("thread diganggu"));
        periksa(new StackOverflowError());
    }
}
