Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core%20Java%20Interview%20Questions%20and%20Answers

Question: What is Checked Exception and its use in java?
Answer:
Checked Exception in Java is all those Exception which requires being catches and handled during compile time. If Compiler doesn’t see try or catch block handling a Checked Exception, it throws Compilation error. All the Exception which are direct sub Class of Exception but not inherit RuntimeException are Checked Exception.

Use of Checked Exception:
1) All Operation where chances of failure is more e.g. IO Operation, Database Access or Networking operation can be handled with Checked Exception.
2) When you know what to do (i.e. you have alternative) when an Exception occurs, may be as part of Business Process.
3) Checked Exception is a reminder by compiler to programmer to handle failure scenario.

Example of checked Exception in Java API
Following are some Examples of Checked Exception in Java library:
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook