Checked and Unchecked Exceptions in Java 

By: Samit Katiyar - samit_katiyar@rediffmail.com

What is the difference between checked and Unchecked Exceptions in Java?

All predefined exceptions in Java are either a checked exception or an unchecked exception. Checked exceptions must be caught using try .. catch() block or we should throw the exception using throws clause. If you don't, compilation of program will fail. 

                            Java Exception Hierarchy

                    +--------+
                    | Object |
                    +--------+
                          |
                          |
                   +-----------+
                   | Throwable |
                   +-----------+
                    /         \
                   /           \
          +-------+          +-----------+
          | Error |          | Exception |
          +-------+          +-----------+
           /  |  \               / |       \
         \________/           \______/      \
                                       +------------------+
          unchecked            checked | RuntimeException |
                                       +------------------+
                                             /   |    |      \
                                            \_________________/
                                           
                                                 unchecked

Have Java Problem
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.