It's not a secret anymore!
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception Handling" Watch "Exception Handling" New topic

Exception Handling

pankaj agarwal
Ranch Hand

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

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

I agree. Here's the link:
subject: Exception Handling
It's not a secret anymore!