This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception Handling" Watch "Exception Handling" New topic
Author

Exception Handling

pankaj agarwal
Ranch Hand

Joined: Oct 13, 2000
Posts: 39
Hi!
I came across this question in one of the tests. Can you help me out on this, please?
Thanks in advance
pankaj
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.


I know option d) is true, is any of the other options true also?
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
a) & b) are false because constructors cannot throw exceptions.
Similarly c) is false because classes do not explictly throw exceptions.
Sean
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi pankaj,
option a,d are correct.
and
constructors can throw exceptions
if u don't belive confirm it by running the following code.

regards
deekasha
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception Handling