Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked Exceptions and Unchecked

 
Binu K Idicula
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime exceptions are unchecked and so does that means a method which throws a runtime exception need not be called from within a try catch block or which throws exception type??
Will there be specific questions asking which are checked and unchecked exceptions ??
IF so which exceptions are to be studied ?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime exceptions are unchecked and so does that means a method which throws a runtime exception need not be called from within a try catch block or which throws exception type??
Yes
Will there be specific questions asking which are checked and unchecked exceptions ??
In the new 1.4 exam, the objectives concerning exceptions are:
- Write code that makes proper use of exceptions and exception handling clauses (try, catch, finally) and declares methods and overriding methods that throw exceptions.
- Recognize the effect of an exception arising at a specified point in a code fragment. Note: The exception may be a runtime exception, a checked exception, or an error (the code may include try, catch, or finally clauses in any legitimate combination).
IF so which exceptions are to be studied ?
You should at least know the most common checked and unchecked exception (ArithmeticException, ClassCastException and the like). Some questions may ask whether some code results in an exception being thrown at runtime (the very effect of unchecked exception) or not. You should be able to recognize that an incorrect cast will result in an exception (ClassCastException) at runtime.
 
Binu K Idicula
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ...for the detailed reply
 
Kumar Kausikasa
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Valentin,
I have a question regarding the exception.IT sayd in RHE book, page no:145, that all the sublcass of java.lang.Exception are checked exception except java.lag.RuntimeException
. But all under the hierarchy of java.lang.Throwable.
What are the ways to recognize which are checked exception and which are not?
a) Do i need to memorize them which are under RuntimeException?
b)As you stated RuntimeException do not require try and catch , is that can be a criteria?
Can you tell me some ways of figuring it out in the code?
Thanks for your time
Praveen
 
Binu K Idicula
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
It seems easy to remember some RuntimeExceptions ..Only a few exceptions listed in the java api are extending RuntimeException ..
say important among these are ...ArithmeticException, ArrayStoreException,ClassCastException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException,NullPointerException,IndexOutOfBoundsException. I hope it is easy to remember these names ,...
regards
Binu K Idicula
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic