This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
class ColorException extends Exception {} class WhiteException extends ColorException {} class White { void m1() throws ColorException {throw new WhiteException();} void m2() throws WhiteException {} public static void main (String[] args) { White white = new White(); int a,b,d,f; a = b = d = f = 0; try {white.m1(); a++;} catch (ColorException e) {b++;} try {white.m2(); d++;} catch (WhiteException e) {f++;} System.out.print(a+","+b+","+d+","+f); }}
What is the result of attempting to compile and run the program?
a. Prints: 0,1,0,0 b. Prints: 1,1,0,0 c. Prints: 0,1,1,0 d. Prints: 1,1,1,0 e. Prints: 1,1,1,1 f. Compile-time error g. Run-time error h. None of the above
answer c.
why exception is not cought for method m2()?
thanks in advance. reena
wise owen
Ranch Hand
Joined: Feb 02, 2006
Posts: 2023
posted
0
void m2() throws WhiteException {} does not throw any exceptions.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: doubt on catching exception on following code