Multiple catch block in Java (Java Course)

preview_player
Показать описание



******************** What is an exception?
An exception is an unwanted or unexpected event, that occurs during the execution of a program.

What is an Error?
It is a serious problem in a program.

What are the causes of Exception?
When a user enters the invalid data.
When a user tries to open a file but that doesn't exist.

What are the types of Exceptions?
Checked Exception:
A checked Exception is an exception that is checked at the compilation-time itself.
Programmer should take care of these checked excpetions.

Unchecked Exception:
An unchecked exception is an exception that occurs during the runtime. These are also called as runtime exceptions.

Exception Hierarchy:
Throwable is the super class for all the Exception classes.

Important Exception Methods:
public String getMessage() : It returns the details message about the exception.
public String toString() : It returns the cause for the exception.
public void printStackTrace() : It prints the stack trace.

How to handle an Exception?
Exception can be handled by using try and catch.
try block:
A try block is placed around the code that might throw an exception.

catch block:
A catch block handles the thrown exception.

Multiple catch blocks:
A try block can be followed by multiple catch blocks.

#finallyblock #Java #programmingline #rakesh #rake

*******************************************************

IMPORTANT PLAYLISTS:

Important Links:

*******************************************************

Subscribe my YouTube channels:

*******************************************************
Рекомендации по теме
welcome to shbcf.ru