It's not a secret anymore!
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception Ques from k&b" Watch "Exception Ques from k&b" New topic

Exception Ques from k&b

NDP Prasad
Ranch Hand

Joined: Apr 13, 2006
Posts: 177
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"; }
// 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

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:
subject: Exception Ques from k&b
jQuery in Action, 3rd edition