do we need to know all unchecked exceptions by name, so that we don't worry about handling them? No, you don't need to know *all* unchecked exceptions by name. I understand checked exceptions should be declared or handled, and unchecked exception don't have to. yup. Or is it safe to assume the only unchecked exception (not Error) that will appear in the exam will be RuntimeException only? do not assume that. You might get questions on errors as well. It is only to test that you know the concepts. is it true to say all subclasses of RuntimeException are the only unchecked exceptions?.. Not the *only* unchecked exceptions. Subtypes of Error and RuntimeExceptions are unchecked exceptions. Have a look at this post: http://www.coderanch.com/t/242534/java-programmer-SCJP/certification/Overriding-methods-Exceptions
I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Joined: Jul 26, 2003
Andres, Thanks for your reply. The explanation and link was helpful. I think Errors might be easy to identify in the exam since all the Error names ends with the word "Error" in it. So that I know, it is an unchecked and don't need to handle. (I realise Errors are different. they are always unchecked. They extend Throwable, not Exception). Since RuntimeException (and its subclasses) are subclasses of Exception, I should be able to identify whether the thrown exception need to handled or not. For example:
With above code, compilor does not complain on exception-1 because it is a subclass of RuntimeException, where as compiler forces you to handle (or declare) exception-2 because it is NOT a subclass of RuntimeException, but at the same it is a subclass of Exception. BUT, going back to my original question, given a scenario where similar question like the above comes up in exam, I should be able distinguish the subclasses of RuntimeException...so that I know it need not be handled ?