File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

faiza haris
Ranch Hand

Joined: Oct 17, 2000
Posts: 173
<if catch throws a new exception, not mentioned with any throws clause, then it will not be handled. The>
reason mainly being that
1)it was not declared in throws
2)there is no mention in try block to handle it.
Plz confirm!

public class divby0{
public void div() throws ArithmeticException{
int n1= 2;
int n2= 0;
try{
System.out.println(n1/n2);
}
catch ( ArithmeticException e)
{
System.out.println("i will catch this exception");throw new RuntimeException ();
}
finally{
System.out.println("finally...going out");
}
System.out.println("over to roger");
}
Santosh Jaiswal
Greenhorn

Joined: Oct 04, 2000
Posts: 26
Here you need a nested try-catch, in Outer try block you need to handle the exception thrown by the statement
throw new RuntimeException ();
Hope this helps.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions
 
Similar Threads
2 objects EXCEPTION
Overriding and Exceptions
fyi: pre/post increment with exception thrown on the line
Comparint contents of 2 files in different folders
trouble with operator