I am studying for the 1.4
java cert.
I am taking on line some mock exam from this site
http://www.danchisholm.net/july21/mybook/chapter9/exam1.html the following block of code is asking about exception, i ran through it and it gave me the answer as: 0,1,1,0,0,1.
But still not sure how to get the answer.
Can anyone walk me through in detail.
Regards.
Here is the code:
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(
String args[]) {
int a,b,c,d,f,g,x;
a = b = c = d = f = g = 0;
x = 2;
try {
try {
switch (x) {
case 1: throw new Level1Exception();
case 2: throw new Level2Exception();
case 3: throw new Level3Exception();
} a++; }
catch (Level2Exception e) {b++;}
finally {c++;}
}
catch (Level1Exception e) { d++;}
catch (Exception e) {f++;}
finally {g++;}
System.out.print(a+","+b+","+c+","+d+","+f+","+g);
}}