Share on Google+Share on Google+

SCJP Module-6 Question-23

Advertisement
The Sample program code given below will test your understanding of try, catch block in Java.

Given below the sample code :

public class Base {
static String str = "-";

public static void main(String[] args) {
try {
throw new Exception();
} catch (Exception e) {
try {
try {
throw new Exception();
} catch (Exception ex) {
str += "MI ";
}
throw new Exception();
} catch (Exception x) {
str += "NU ";
} finally {
str += "S ";
}
} finally {
str += "SIGN ";
}
System.out.println(str);
}
}

What will be the output of the above code?

1.No output

2.S SIGN

3.MI NU S SIGN

4.- MI NU S SIGN

Answer

(4)

Advertisements

Posted on: July 15, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.