• 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

Basics of exception handling

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For you all who are putting lot of hard work to get certified.
My question is very simple.
Why there is a special methods( like try, catch, finally etc.) to
detect any exception. How it is handled in other languages like
c or c++ or Fortran.( as I donot know any other computer language)
If Runtime exception are handled by java runtime environment then why not there is such provision to handle other kind of exception. I mean to say why the language has not been designed to take care of all exception so as to ease the programmer
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am in the same boat as you. i dont know any other modern computer languages either. I have heard that VB provides for checked exceptions but I dont think C++ does.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C++ definitely has exception handling mechanisms. Java got it from C++. However, C doesn't. You have to check return code for errors. Any RuntimeExceptions will either result in corrupted data or segmentation faults (core dump). Regarding Fortran, I don't remember it having exception handling either. Its been too long since I used it.
Now to answer why you need exception handling like try, catch. Its simple. It forces the developer to handle all possible exceptions. If it was just return codes, developers may forget to check them.
RuntimeExceptions and Errors are handled by the runtime environment because they can't be detected during compile time. All other exceptions are handled during compilation. So, in essence, all exceptions are handled one way or another.
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exception handling in other languages are more or less decided by the developers, because this, many programs have many bugs that simply missed by the developers.
The Java programming language solve this major problem by forcing developers to habdle exceptions, which eliminates many unnecessary bugs.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic