UrbanPro
true

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Difference Between Checked And Un-Checked Exception

Md Ajmat
16/01/2018 0 0

1. Exception is an abnormal condition in the program, if raises program terminates abnormally.

2. Exception always occurs at runtime only, there is no chance of exception at compile time.

3. Syntactical mistakes or errors are occurs at compile time.

4. All Exceptions are the pre-defined class in java.

5. Throwable is the root of all java Exceptions.

 

a. Checked Exception are Exception that has been checked by the compiler at compile time for the smooth execution of program at runtime. It doesn't mean the Excception has raised at compile time.

1. If there are any checked exception is raised at compile time means compiler concerned about how you will handle that condition at runtime. The Compiler will ask you for alternative code.

2. In case of checked exception compiler tries to know how you will handle the situation, so the alternate code they needed, by knowing this they will compile your code.

Ex-Except RuntimeException and Errors every Exceptions are checked in java.

Case 1.) If you are trying to read some file content through java code, in that case compile always concerned about "if file will not available at runtime then what will you do?". You have to give the alternate code by placing some local file.

FileReader fr=new FileReader("abc.txt");//it will throw Checke Exception

Case 2.) If you are tries to load some class at Runtime, in that case compiler will concerned about "if there is no availability of specified class, they how will you handle that situation".

Class.forName("oracle.jdbc.driver.OracleDriver"); //it will throw Checked Exception

Solution:This situation can be handled either by using 

1) Try-catch block,

2) Throws keyword,

 

Un-Checked Exception:

1. These are the exception about which compiler is not aware.

2. If there are any un-checked exceptions occurs,compiler won't ask for handling code.

3. All Errors and RuntimeException are un-checked by nature.

4. We can handle the situation only by using try-catch block.                                      

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Priority in TestNG
public class Priority { @Test (priority=1)public void login() {System.out.println("login");} @Testpublic void email1() {System.out.println("email1");} @Test (priority=-2)public void email2() {System.out.println("email2");} //I...
S

Sarthak C.

0 0
0

Why We Should Go With Java?
Java is widely used in the Desktop application, web application, mobile development, games etc. Java is an object-oriented programming language. Its follow all the oops concept Like Object, Class,...
B

Bhupendra Patidar

0 0
0

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

JAVA - Object Cloning
JAVA - Object Cloning Is the way of creating the same copy of object without calling the class constructor. It means we can make any class object multiple times without calling its default constructor....
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more