File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions " Watch "Exceptions " New topic


Chris Judd

Joined: Feb 25, 2007
Posts: 23
I'm having a hard time understanding why E is considered a correct answer to this question. The book lists NumberFormatException as a Programmatically throw exeption. I thought that means that it is a checked can I tell what is a checked excption and what is an unchecked exception?

Thanks for your help,

From 400 Chapter 5: Flow Control, Exceptions, and Assertions of the K & B book:

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.)
A. String doFileStuff() { return "b"; }
B. String doFileStuff() throws IOException { return "b"; }
C. String doFileStuff(int x) throws IOException { return "b"; }
D. String doFileStuff() throws FileNotFoundException { return "b"; }
E. String doFileStuff() throws NumberFormatException { return "b"; }
F. String doFileStuff() throws NumberFormatException,
FileNotFoundException { return "b"; }
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
An unchecked exception is either RuntimeException, Error, or one of their subclasses.

In this case, you are not required to list the classes in the throws clause of the overriden method in the throws clause of the overriding method.

Also you are allowed to add unchecked exception to the throws clause of the overridding method.
Chris Judd

Joined: Feb 25, 2007
Posts: 23
Thanks Keith!
I agree. Here's the link:
subject: Exceptions
It's not a secret anymore!