public class Solution { public static StatelessBean BEAN = new StatelessBean(); public static void main(String[] args) { try{ handleExceptions(); } catch(FileSystemException exeption) { BEAN.log(exeption); } } public static void handleExceptions() { try{ BEAN.methodThrowExceptions(); } catch(FileSystemException exeption) { BEAN.log(exeption); throw exeption; } catch(CharConversionException e) { BEAN.log(e); } catch(IOException ex) { BEAN.log(ex); } } public static class StatelessBean { public void log(Exception exception) { System.out.println(exception.getMessage() + ", " + exception.getClass().getSimpleName()); } public void methodThrowExceptions() throws CharConversionException, FileSystemException, IOException { int i = (int) (Math.random() * 3); if (i == 0) { throw new CharConversionException(); } else if (i == 1) { throw new FileSystemException(""); } else if (i == 2) { throw new IOException(); } } } }