File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes need guidance 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 "need guidance" Watch "need guidance" New topic

need guidance

Rajesh k Jha
Ranch Hand

Joined: May 10, 2009
Posts: 72

The result of this programme is compilation fail..What i guess is if we are sure that in the try block if it is 100% surity that exception will be thrown as we can see in the line 1, then there should not be any line below that? Please guide me if i wrongly understood the concept?
Samrat Som
Ranch Hand

Joined: Feb 04, 2009
Posts: 40
yep rakesh you are correct . As the Code is unreachable. You will get an Compilation error saying Unreachable Code.

SCJP 1.6
SCWCD 1.5 (Preparing...)
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

the surity is given by the throw keyword. If it were a risky statement then probably this won't be a correct answer. Also other part is if you are catching a checked exception means your try block should have a statement which threatens to throw a checked exception. If not then there will be compiler error again.

[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

The following page explains how to use code tags:

In particular: write "code" with a small c, don't write [Code]. Note that above the editing window, there is a button named "Code" that you can click to start or end a code block.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: need guidance
It's not a secret anymore!