Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Easy way to remember Checked Exception Rules?

 
Greenhorn
Posts: 12
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

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.

Ainsley.
 
Marshal
Posts: 65763
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!