• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exceptions -- checked versus unchecked.... and which ones are which

 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so I understand that a checked exception results in a compile time error, and unchecked exceptions result in runtime errors.

I think I understand why (because the compiler "checks" for the checked exceptions... if you're running, you've been checked?).....

I remember the common runtime exceptions.... null pointer, class cast, arithmetic. And the common compiler time exceptions.... IO, class/method not found, SQL.

Now I'm looking at the API. There's like fifty of each. How many of these do I really need to know? I mean, is UnsupportedFlavorException really on the exam (I know the compiler hates cherry flavor, but come on!)?

I have the K&B SCJP6 book.... I just can't find any list of ones I need to memorize. And I'm not sure how much is extensive API memorization versus just knowing conceptually which one is going to cause a compile/run time error (and thus which needs to be caught).

Any tips?
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Janeice DelVecchio wrote:Okay, so I understand that a checked exception results in a compile time error, and unchecked exceptions result in runtime errors.

I think I understand why (because the compiler "checks" for the checked exceptions... if you're running, you've been checked?).....



Checked exception- Are thrown when the program is executing and they need to be supported by throws clause or the try...catch block. Any attempts to compile the code without any of these- throws/try...catch for Checked exceptions would result in a compiler error. But Checked exceptions itself don't result in a compile time error.

Same goes with Unchecked exceptions- These need not be handled by the code as they are usually unexpected errors/exceptions. This link briefly explains the two.

Janeice DelVecchio wrote:
I remember the common runtime exceptions.... null pointer, class cast, arithmetic. And the common compiler time exceptions.... IO, class/method not found, SQL.

Now I'm looking at the API. There's like fifty of each. How many of these do I really need to know? I mean, is UnsupportedFlavorException really on the exam (I know the compiler hates cherry flavor, but come on!)?

I have the K&B SCJP6 book.... I just can't find any list of ones I need to memorize. And I'm not sure how much is extensive API memorization versus just knowing conceptually which one is going to cause a compile/run time error (and thus which needs to be caught).

Any tips?


From the Objectives in the Flow Control Section:

Section 2 Flow Control wrote: Recognize situations that will result in any of the following being thrown: ArrayIndexOutOfBoundsException,ClassCastException, IllegalArgumentException, IllegalStateException, NullPointerException, NumberFormatException, AssertionError, ExceptionInInitializerError, StackOverflowError or NoClassDefFoundError. Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programatically.



So I think one has to know these exceptions. There would be questions which relate to which exception might be thrown or to categorize the exceptions as Unchecked/Checked.

 
Janeice DelVecchio
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! That is very helpful. And the link is easier to understand than some of the other pages I've looked at about checked vs unchecked....

Do you suppose that the list in the flow control objectives contains the only exceptions that need to be memorized?

EDIT.... those are all unchecked or errors. Is there a list of checked exceptions to memorize?
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Janeice DelVecchio wrote:
Do you suppose that the list in the flow control objectives contains the only exceptions that need to be memorized?



I think that's it to be known from the point of exam. And also Flow Control mentions other topics related to Exceptions. But the list of Exceptions they have provided are often encountered in the other objectives being covered like-NumberFormatException in parsing String to int(or other type), IllegalStateException in Threads(?) . If you consider Exceptions related to SQL/JDBC, as SQL/JDBC are not part of the SCJP objectives. Also you should be aware of any Exceptions which are mentioned in the other objectives- like the File IO related excpetions.

Edit: Checked exceptions come under the different objectives- so any API part of the objective and it throws some error- One has to know about it But what ever mentioned in the K&B guide is more than enough. Would like to hear from other Ranchers regarding this. While I was preparing I didnt worry about exceptions not mentioned in the book- either in the Code examples or in the text.
 
reply
    Bookmark Topic Watch Topic
  • New Topic