Just done a mock test on sybex for the Java SE8 exam and scored 60 percent.
Kicking myself for the wrong answers I got but, still moving forward.
What seems to be bugging me is checked and unchecked exceptions with code.
I understand that checked exceptions must be handled (using a try and catch block) or declared (thrown again outside of the method). Yet applying these theories to when a question comes up seems tricky.
Does anyone have an easy way to remember how an unchecked exception doesn't need to be thrown again? I know it's different in the fact that if child classes method that throws a checked exception the parent must throw a broader or the same one, but it's completely different for runtime exceptions.
Anyway, I hope that makes sense and thanks in advance.
Ains Clark wrote:. . . Just done a mock test . . . and scored 60 percent.
You must have more to revise than only checked/unchecked exceptions, I am afraid. You will have found out that cert exam questions are much more difficult than they look
. . . checked exceptions must be handled . . . or declared (thrown again outside of the method).
Declaring an exception doesn't mean you have to re‑throw it; it might simply mean you are not catching it. There is a nice section about handle or declare in the Java™ Tutorials.
. . . Does anyone have an easy way to remember how an unchecked exception doesn't need to be thrown again?
I think it is more a case that unchecked exceptions are allowed to propagate unchecked until they crash your app. You are not obliged to do anything with unchecked exceptions
. . . different for runtime exceptions. . . .
I think it is Ken Kousen who says that RuntimeException is the worst name for a class ever. Don't say “runtime exception” in two words, not even if the Java™ Tutorials say that; say, “unchecked exception”. All exceptions occur at runtime; an exception occurring at other times is like dry rain: a contradiction in terms. You are allowed to ignore unchecked exceptions; that is the easy way to think about it.
The number of exception classes likely to appear in a cert exam will be limited. You should be able to learn about twenty types of Exception and remember which are or aren't checked. The official nomenclature With or without Capital Letters appears in the Java® Language Specification; you may only need to read the §11.1.1.
What are your superhero powers? Go ahead and try them on this tiny ad: