Selenium 6
Selenium 6
Throwable Class
Errors Exception
Errors : - Error refers to an illegal operation performed by the user which results in the abnormal working of the program.
Programming errors often remain undetected until the program is compiled or executed. Some of the errors
inhibit the program from getting compiled or executed. Thus errors should be removed before compiling and
executing. It is of three types:
•Compile-time
•Run-time
•Logical
Exeption:-
An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e at run time,
that disrupts the normal flow of the program’s instructions. In Java, there are two types of exceptions:
1.Checked exceptions.
2.Unchecked exceptions
1.Checked Exception:-
These are the exceptions that are checked at compile time. If some code within a method throws a
checked exception, then the method must either handle the exception or it must specify the exception using
the throws keyword.
2.Unchecked Exception :-
These are the exceptions that are not checked at compile time.
Errors Exceptions
All errors in java are unchecked type. Exceptions include both checked as well as unchecked type.
Errors can occur at compile time as well as run time. Compile Time:
All exceptions occurs at runtime but checked exceptions are known
eg Syntax Error
to the compiler while unchecked isnot.
Run Time: Logical Error.
They are defined in java.lang.Error package. They are defined in java.lang.Exception package
Java try block is used to enclose the code that might throw an exception. It must be used within the method.
If an exception occurs at the particular statement in the try block, the rest of the block code will not execute. So, it is
recommended not to keep the code in try block that will not throw an exception.
Syntax:-
try
{
block of code which can throw exception
}
catch(ArithmeticException e) //exception to be handeled
{
Statement/ code to be executed when the exception occurs
}