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
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.
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.