• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Exceptions  RSS feed

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could i know which exceptions are checked and which are not???
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exceptions which inherit from java.lang.RuntimeException or java.lang.Error class are unchecked, all other are checked...
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All non run-time exceptions are checked exceptions.
 
ujjawal rohra
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But is there any way so that i can tell which are checked and which are unchecked only by reading their names
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Rancher
Posts: 425
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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,
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 310
1
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
     
    author
    Posts: 8981
    19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!