It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Checked Exceptions Vs RuntimeException 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 "Checked Exceptions Vs RuntimeException" Watch "Checked Exceptions Vs RuntimeException" New topic

Checked Exceptions Vs RuntimeException

manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Can any please explain me the difference between Checked Exceptions and java.lang.RuntimeException with nice examples.

Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
there are two type of exceptions, checked and unchecked. The checked exception are all of the exceptions that extend Exception, except RuntimeException and is subclasses. RuntimeException and it sublclasses along with Error and its subclasses are all considered unchecked exceptions.
The checked vs unchecked part comes from what the compiler does. In a checked exception the compiler will check to make sure that the exception is used properly and caught/handled properly. They are checked exceptions becasue it si reasonable assumed that the exceptional condidtion can and should be found and fixed by the programmer not by the end user.
The unchecked exception is just the opposite it is assumed that are caused by conditions over which the programmer has no control , a lost connection, out of memory, etc.
hope that helps out a little

Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Hi, Murthy
Sometimes use search for getting fast answer.. I searched "checked" keyword and got a lot of useful thread links.
I can suggest this thread to you.
Jamal Hasanov
I agree. Here's the link:
subject: Checked Exceptions Vs RuntimeException
It's not a secret anymore!