aspose file tools*
The moose likes Beginning Java and the fly likes java exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java exceptions" Watch "java exceptions" New topic
Author

java exceptions

Adi Sharma
Ranch Hand

Joined: May 18, 2009
Posts: 33
Hi,

I came across the following:

void doStuff()
{
doMore();
}
void doMore() throws IOEXception
{
throw new IOException();
}


In this code the method doStuff() does not declares nor does it handles the IOException thrown by doMore() function. If doStuff() also declares a IOException and does not handles the exception using a try catch block, the method that is further down in the call stack should handle it. What if the last method in the call stack also does not handles it. Will it be a compile time error?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18139
    
  39

Will it be a compile time error?


It is not too hard to write a test program -- to compile. Give it a test, and let us know the results.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java exceptions
 
Similar Threads
Chapter 5 of SCJP Java 6 book of Kathy Sierra/Bert Bates
Exception Handling
Exception Wondering
Question on "Handle Or Declare" rule for Exceptions - K&B book Page 374 (Exam Watch)
custom exception