Java Reference
In-Depth Information
< Day Day Up >
Puzzle 37: Exceptionally Arcane
This puzzle tests your knowledge of the rules for declaring exceptions thrown by methods and
caught by catch blocks. What does each of the following three programs do? Don't assume that all
of them compile:
import java.io.IOException;
public class Arcane1 {
public static void main(String[] args) {
try {
System.out.println("Hello world");
} catch (IOException e) {
System.out.println("I've never seen println fail!");
}
}
}
public class Arcane2 {
public static void main(String[] args) {
try {
// If you have nothing nice to say, say nothing
} catch (Exception e) {
System.out.println("This can't happen");
}
}
}
 
 
Search WWH ::




Custom Search