Author | Topic: Mock exam question (exceptions) |
Dre unregistered |
posted March 31, 2000 03:50 PM
In regards to exceptions, which of the following are true? a) An exception can be thrown by a no argument constructor. b) An exception can only be thrown by a multi argument constructor. c) Uncaught exceptions should be listed in the throws clause of a class definition. d) In all cases except exiting the JVM, the finally clause of a try block is executed. My answer : a c d <<< is this correct?>>
|
Just For A Moment greenhorn |
posted April 01, 2000 04:57 AM
Yup, U r correct.
|
Just For A Moment greenhorn |
posted April 01, 2000 05:07 AM
hi, yes ur correct.
|
Milind ranch hand |
posted April 01, 2000 08:21 AM
I think option B is also correct !! Multi argument constructors can throw Exceptions using the 'throws' clause. In the JLS all they say is that: the throws clause of the construcor is identical in structure and behavior to the throws clause of a method. So I guess both B can throw Exceptions. Hope this helps !! Regds, Milind
|
maha anna bartender |
posted April 01, 2000 08:25 AM
Miland, Please read the qstn once more. It says, An exception can only be thrown by a multi argument constructor. > This only word makes the answer false. Because other overloaded constructors also CAN throw Exception at their will. So ans a) c) d) are correct regds [This message has been edited by maha anna (edited April 01, 2000).]
|
Milind ranch hand |
posted April 01, 2000 09:34 AM
Thanks Maha Anna !! Regds, Milind
|
Javix Protocol ranch hand |
posted April 01, 2000 12:38 PM
Yep what maha anna told is correct! ------------------
|
JRoch unregistered |
posted April 01, 2000 03:55 PM
My preceding message didn't show.. ? I'll give it a try again: I think the answers are only a) and d). Only METHODS can declare they throw Exceptions. Not CLASSES. JRoch
|
maha anna bartender |
posted April 01, 2000 08:30 PM
Yes. Yes. I was concentrating on the only part of the other answer only. c) is wrong. Thanks JRoch for pointing out the catch. regds maha anna
|
rch-tech unregistered |
posted April 07, 2000 02:01 PM
Well, I am a newbie and haven't registered yet, but I have to say that D isn't quite correct either. The finally clause may not be exectued if the JVM exits, but also if the Thread executing the code containing the finally dies, not throws an exception but dies. Is this true?? rch-tech
|
| | |