File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Basics of exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Basics of exception handling" Watch "Basics of exception handling" New topic

Basics of exception handling

mahesh deshpande

Joined: Oct 26, 2000
Posts: 19
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
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

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.

Visit my download page
Sam Wong
Ranch Hand

Joined: Dec 07, 2000
Posts: 133
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.
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
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.
I agree. Here's the link:
subject: Basics of exception handling
It's not a secret anymore!