Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checked Exceptions Vs RuntimeException

 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any please explain me the difference between Checked Exceptions and java.lang.RuntimeException with nice examples.
thanks
murthy
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Murthy
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
regards,
Jamal Hasanov
www.j-think.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic