• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need guidance

 
Rajesh k Jha
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep rakesh you are correct . As the Code is unreachable. You will get an Compilation error saying Unreachable Code.
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15458
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following page explains how to use code tags: http://faq.javaranch.com/java/UseCodeTags

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic