What is the output after the following is executed


What is the output after the following is executed?


class Exception1 extends Exception {

public String toString() { return "Exception1"; }

}

class Exception2 extends Exception {

public String toString() { return "Exception2"; }

}

public class Problem1 {

public static void main(String[] args) {

try {

method1();

System.out.println("Back from method1");;

} catch(Exception e) {

System.out.println(e + " caught in main");

}

method3();

System.out.println("Back from method3");

System.exit(0);

} // end main;


static void method1()throws Exception2 {

method2();

System.out.println("Back from method2");

} // end method1

static void method2() throws Exception2 {

throw new Exception2();

} // end method2

static void method3() {

try {

method5();

System.out.println("Back from method5");

} catch(Exception1 e) {

System.out.println(e + " caught in method3");

}

} // end method3

static void method5() throws Exception1 {

throw new Exception1();

} // end method5

} // end Problem1

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: What is the output after the following is executed
Reference No:- TGS0133553

Expected delivery within 24 Hours