X (Lec-28) Java SE (Exception Handling-2)
X (Lec-28) Java SE (Exception Handling-2)
(CORE JAVA)
LECTURE-28
Today’s Agenda
• Now using that object we can obtain all the possible details
of the exception that occurred in the catch block.
Checked Unchecked
Exceptions Exceptions
Exceptions for which java forces the Exceptions for which java never
programmer to either handle it using compels the programmer to
try-catch or the programmer must handle it.
inform or warn the caller of the The program would be compiled
method that his code is not handling and executed by Java.
the checked exception. Example the class
The warning given is through the RuntimeException and all its
keyword throws. It is used in the derived classes fall in this
method ‘s prototype along with category.
exception class name.
Checked Exception
import java.io.*;
class Input
{
public static void accept( ) throws IOException
{
System.out.println(“Enter a character”);
char c=(char)System.in.read( );
System.out.println(“You entered ”+c);
}
}
class UseInput
{
public static void main(String [] args) throws IOException
{
Input.accept( );
}
}
End Of Lecture 28