This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
How could i know which exceptions are checked and which are not???


SCJP 6
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Exceptions which inherit from java.lang.RuntimeException or java.lang.Error class are unchecked, all other are checked...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
All non run-time exceptions are checked exceptions.
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 101
But is there any way so that i can tell which are checked and which are unchecked only by reading their names
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

ujjawal rohra wrote:But is there any way so that i can tell which are checked and which are unchecked only by reading their names

Only *magician* can tell that
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 771
I don't think so, you gotta check the official documentation for that. But for the exam, there are certain
very common exceptions which are used like NumberFormatException, NullPointerException. Many of the common ones
i guess you can remember are run-time or not.

Best Regards,


Prithvi/Beenish,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
ujjawal rohra wrote:But is there any way so that i can tell which are checked and which are unchecked only by reading their names


There is no such way
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

Seetharaman Venkatasamy wrote:
ujjawal rohra wrote:But is there any way so that i can tell which are checked and which are unchecked only by reading their names

Only *magician* can tell that

Or the original coder
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 771
Pushkar Choudhary wrote:
Seetharaman Venkatasamy wrote:
ujjawal rohra wrote:But is there any way so that i can tell which are checked and which are unchecked only by reading their names

Only *magician* can tell that

Or the original coder


or the JavaDocs

hth,
Larry Chung
Ranch Hand

Joined: Feb 02, 2010
Posts: 245
ujjawal rohra wrote:How could i know which exceptions are checked and which are not???


Most programmers know the difference between checked and unchecked exceptions by:

1. a lot of years of programming experience

2. memorizing the names of a few checked and unchecked exceptions

3. "being the compiler".
For example, if you are the compiler, can you always predict that some code will throw a NullPointerException? No. Therefore, it must be a runtime (a.k.a. unchecked) exception.


SCJP 6
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

ujjawal rohra wrote:How could i know which exceptions are checked and which are not???

this moslty comes with experience. For the exam purpose you need to know the common exceptions related to exam objectives and should be able to identify which are checked and which are not. For example the following are all checked exceptions. You either need to declare using "throws" or handle in a "try" "catch" block.
  • InterruptedException
  • ParseException
  • IOException
  • ClassNotFoundException
  • FileNotFoundException

  • If you don't remember these, and if these comes in an overriding question, you wont be able to answer it correctly!

    the following are unchecked exceptions (or Runtime Exceptions). You don't need to handle or declare these!
  • NullPointerException
  • ArithmeticException
  • IllegalArgumentException
  • IllegalStateException
  • ArithmeticException
  • IllegalMonitorStateException
  • NumberFormatException
  • IllegalThreadStateException


  • good luck


    SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
    Bert Bates
    author
    Sheriff

    Joined: Oct 14, 2002
    Posts: 8712
    Hi Ujjawal,

    Do you know why they're called 'checked' exceptions? If you get really clear on that question it can help you remember which are which.


    Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Exceptions
     
    Similar Threads
    exceptions
    which block in exceptions controls resource leaks
    Assertions
    while loop
    writing from a jar