• 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

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are unchecked exceptions and those thrown by the JVM the same?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pradeepta chopra:
are unchecked exceptions and those thrown by the JVM the same?



Short Answer: yes


Longer Answer:
Anything that prevents compilation = checked.
These are "checked for" during compilation - For instance, the compiler makes sure you handle IOException if you're reading from a file.

Anything that surprises you during runtime = unchecked.
If your task is to "print the 2nd command line argument" and are only supplied with one argument, you'll get an unchecked ArrayIndexOutOfBoundsException when you try to access arg[1].

I would highly recommend making small examples to help clarify any "what happens if" doubts. I like Eclipse as it quickly alerts me to compiler issues while I type.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well you can say that all JVM exceptions are unchecked but not vice versa. Like IllegalArgumentException is unchecked, but it is thrown explicitly. Another example would be NumberFormatException. There are so many such examples...
 
pradeepta chopra
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic