Java
class AllBlocks Demo public static void main(String args[]) { String citylist[] = {"Ahmedabad", "Baroda", "Rajkot", "Surat"); int numerator = 15, denominator = 0, answer: System.out.println("Statement to be executed before try block"); try { System.out.println("Begining of try block..."); System.out.printin(citylist[5]); // Generates ArrayIndexOutOfBoundsException answer numerator / denominator; // Generates ArithmeticException System.out.println("End of try block..."); } catch(ArrayindexOutOfBoundsException eobj) { } System.out.println("Within first catch block, exception caught:" + eobj); catch(ArithmeticException eobj) { System.out.println("Within second catch block, exception caught:" + eobj); } catch(Exception eobj) { System.out.println("Within last catch block, exception caught:" + eobj); //Generic block System.out.println("This part of code will always get executed");