class ColorException extends Exception {}
class WhiteException extends ColorException {}
abstract class Color {
abstract void m1() throws ColorException;
}
class White extends Color {
void m1() throws WhiteException {throw new WhiteException();}
public static void main (
String[] args) {
White white = new White();
int a,b,c,d;
a = b = c = 0;
try {
white.m1();
a++;
} catch (WhiteException e) {b++;}
finally {c++;}
System.out.print(a+","+b+","+c);
}
}
Step by step Analysis, Please correct me.
-----------------------------------------
class ColorException extends Exception {}
ColorException is subclass of Excpetion
class WhiteException extends ColorException {}
WhiteExcpetion is subclass of ColorException
abstract class Color {
abstract void m1() throws ColorException;
What is going on here? Please explain.Is the method m1() going to use ColorException class?
}
class White extends Color {
White is subclass of Color
void m1() throws WhiteException {throw new WhiteException();
What is going on here? Please explain. Is method m1()goint to use some oneWhiteException?
}
public static void main (String[] args) {
White white = new White();
int a,b,c,d;
a = b = c = 0;
try {
white.m1();
which method will get called?
1.abstract void m1() or
2. void m1() Please explain
from down I know whats going on
a++;
} catch (WhiteException e) {b++;}
finally {c++;}
System.out.print(a+","+b+","+c);
}
}
I really appreciate. Thanks.