posted 22 years ago
Hi.
I encountered the following question in Jxam.
----------------------------------------------
Suppose a MyException should be thrown if Condition() is true, which statements do you have to insert ? Select all correct Answers
1: public aMethod {
2:
3: if (Condition) {
4:
5: }
6:
7: }
A) throw new Exception() at line 4
B) throws new MyException() at line 4
C) throw new MyException() at line 6
D) throws new Exception() at line 2
E) throws MyException at line 1
----------------------------------------
My answer was only E).
Jxam says answer is E) & B)
I tested it out with jdk1.3 & got the following result when I plugged in choice B) in the code.
ExceptionHandling.java:6: illegal start of expression
I think this is probably a typo error by the Jxam developer. There is an additional 's' in the choice B).
The choice B) should read as follows ...
B) throw new MyException() at line 4
- Himanshu
Himanshu Jhamb<br />SCJP2 v1.2 (April 2002)<br />SCJP2 v1.4 (May 2002)