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 Exception Ques from k&b Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception Ques from k&b" Watch "Exception Ques from k&b" New topic
Author

Exception Ques from k&b

NDP Prasad
Ranch Hand

Joined: Apr 13, 2006
Posts: 177
import java.io.*;
class Master {
String doFileStuff() throws FileNotFoundException { return "a"; }
}
class Slave extends Master {
public static void main(String[] args) {
String s = null;
try { s = new Slave().doFileStuff();
} catch ( Exception x) {
s = "b"; }
System.out.println(s);
}
// insert code here
}

Which, inserted independently at // insert code here, will compile, and produce the output b? (Choose all that apply.)

String doFileStuff() throws IOException ( return "b"; }

I was not able to understand, why the above statement(in Bold) is giving compilation err.
please explain this....Thank U


SCJP,SCWCD<br />
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I assume that the '(' before the return is a typo, it should be '{'.

What does the error message mean to you? Reading the error message carefully will give you a very good idea of what is wrong.
[ December 26, 2006: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
NDP Prasad
Ranch Hand

Joined: Apr 13, 2006
Posts: 177
Thank you Mr.Barry Gaunt. I have just copy pasted from the Book.



The problem is IOException is above the FileNotFoundException in the hierarchy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception Ques from k&b
 
Similar Threads
mock question about exceptions...from K&B SCJP book
Question about Exceptions
Exceptions
K&S Chapter 5 q-3
Exception handling question K&B