• 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

programmatic Exceptions

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am reading the K&B book (chapter 5), and i have doubts about the concept of "programmatic Exceptions".
If i look at the diagram that distinguish exceptions thrown by the JVM and those thrown "programmatically" i can see that all these exceptions are runtime exceptions or errors

I have 2 questions:
- "programmatic Exceptions" are always runtime exceptions or Error ?
-Do they have differences with the syntax (throws , throw ,catch.....)?
 
Greenhorn
Posts: 17
Java ME C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

"throws" is used for checked exception, this exception is specified at method declaration. Caller of this method must handle the exception or must throw it to its caller. If checked exception is not handled or not passed to the caller compiler will not compile the source code.
"throw new ExcetionName" is run time exception. User can throw exception explicitly using "throw new" key word.

When exception is thrown we can handle them by using try... catch...

 
Emmanuel Aron
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the answer , but are you sure that '"throw new ExcetionName" is run time exception' , i have a serious doubt about it.
What do you mean with that?
 
Mak Smash
Greenhorn
Posts: 17
Java ME C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry for late replying but ya we use throw new to raise runtime exception. we can throw a chacked exception using throw new at runtime
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic