What will be the output of the following code :
class Example18{
static String q = "Hello ";
public static void main(String[] args) {
new Example18().subclass1();
System.out.println(s);
}
void subclass1() {
try {
subclass2();
} catch (Exception e) {
q += "Friends";
}
}
void subclass2() throws Exception {
subclass3();
q += "and";
subclass3();
q += "Brothers";
}
void subclass3() throws Exception {
throw new Exception();
}
}
What will be the output of the code :
1. Hello Friends
2. Hello
3.Friend
4.Compile error
Because 'subclass3' raised exception explicitly due to this, the only execution occurs in the 'catch' block of 'subclass1'.