• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
pankaj agarwal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic