aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception question." Watch "Exception question." New topic
Author

Exception question.

jaman tai
Ranch Hand

Joined: Sep 26, 2005
Posts: 37
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.

are the answers a and d. what is the meaning of d?
premraj cheguri
Greenhorn

Joined: Feb 20, 2005
Posts: 21
hi Jaman,

i think D is talking about System.exit(1); In this case the finally cluase will not be executed
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
Regarding answer d :



If you execute this code, "finally-1" will be printed, ok ?
(This demonstrate "In all cases, the finally clause of a try block is executed")
But if you uncomment the line System.exit(0), there's no output (JVM exiting before finally block can be executed).

Hope that hepls.


Regards,<br />Seb<br /> <br />SCJP 1.4
jaman tai
Ranch Hand

Joined: Sep 26, 2005
Posts: 37
oh, you are right! , thanx!
Mandy Hou
Greenhorn

Joined: Oct 15, 2005
Posts: 21
the finally clause of a try block is executed regardless catch or uncatch exception .Except exit JVM by system.exit(1).


Regards<br />Mandy<br /> <br />-----------------<br />Thinking,Thinking,Thinking,<br />Before you do any action!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception question.