If I write a code like the one below why does it not give a compilation error. If I change Exception to IOException it does throw a compilation error.
Question 2 ----------
If an IOException is thrown, then even an Exception can catch it because it is its super class. Then why not an Object.
Joined: Feb 07, 2005
The exceptions that are subclasses of RuntimeException are unchecked. So by catching an Exception you are looking for a wide range of exceptions. But if you choose a specific checked exception, then you need to make sure there is some code in the try block that has the potential for throwing that exception.
The parameter in the catch block must be a subclass of Throwable.
Joined: Jan 06, 2005
Further to what Keith said, I think question one also involves "implicit import" of java.lang.* library. I read somewhere that this happens, but I dunno much about it.