WEBVTT

00:00.000 --> 00:04.000
In this video we are going to
discuss built-in exceptions

00:04.000 --> 00:08.000
We know that exceptions in Java
can be divided into two categories

00:08.000 --> 00:17.000
One is the built-in exceptions, another one is the user-defined exceptions.
So in this case, we are concentrating only on the built-in exceptions

00:17.000 --> 00:23.000
that is some exceptions which are predefined within
this Java language can be used in our coding

00:23.000 --> 00:29.000
So some built-in exceptions are listed
here. So Java has some predefined exceptions

00:29.000 --> 00:33.920
defined exceptions and all exceptions
are the subclass of the exception class

00:34.640 --> 00:38.780
So, Thrable is a class which is
having the package that is Java

00:38.780 --> 00:46.060
. . . So, Java.Lang dot Throbble. So it
has got inherited to the two subclasses

00:46.060 --> 00:49.560
So one is the errors. So it is
having the class that is the Java

00:49.560 --> 00:55.260
. . . . . . . . . . . . . . . . . exceptions,
which is having the class that is a Java. length

00:55.560 --> 01:03.860
Under this Java. .Lang. class we are having multiple
different subclasses so some of them are out of memory

01:03.860 --> 01:26.322
error stack overflow error etc and this java langdot exception is a superclass for multiple different subclasses so i exception SQL
exception file not found exception class not found exception we having this Java Lankt runtime exception which is having some subclasses here

01:26.722 --> 01:33.202
arithmetic exception, null pointer exception, index
out of bounds exception, illegal argument exception

01:33.202 --> 01:38.002
and etc. So this is a hierarchical
diagram partial we have shown here

01:40.002 --> 01:48.182
Now, let us go for some built-in exceptions. So, arithmetic exception. From the
name, it is quite obvious that when you'll be doing some arithmetic operations

01:48.362 --> 01:52.082
and if you find some exceptions are
occurring, then this exception will be thrown

01:52.802 --> 01:59.662
So, arithmetic errors such as divide by
zero. So, array index out-of-bounds exception

01:59.962 --> 02:06.222
From the name, it is quite obvious that I'm trying
to access some subscript or the location of an array

02:06.222 --> 02:16.602
which is beyond the definition. So index exceeds the risk. range of the array.
So in those cases, this array index out of bounds exception will be thrown

02:17.362 --> 02:36.205
Null pointer exception invalid use of null reference Number format exception invalid conversion of a string to a numeric
format So in those cases this number format exception may be thrown no such method exception we are going for another

02:36.205 --> 02:42.405
type of no such method exception a
requested method does not exist so in this

02:42.405 --> 02:46.545
we are having different exceptions we
are having the different descriptions so

02:46.545 --> 02:50.565
for the better understanding let us go
for one practical demonstration for the

02:50.565 --> 02:59.805
ease of your knowledge generation here in this Java program
I have defined one integer array the name of the array is my

02:59.805 --> 03:04.965
array which is having five consecutive
locations so five elements we have put

03:04.965 --> 03:10.005
into this array and during initialization
of this array we have also mentioned

03:10.005 --> 03:14.325
the size of the array that means it is
having five consecutive locations and the

03:14.325 --> 03:19.905
subscript will be ranging from zero to four
so if any subscript if we mentioned which

03:19.905 --> 03:24.985
is beyond this range then obviously
one exception will be occurring so here

03:24.985 --> 03:29.325
here we are printing the value of this
array from the subscript number 10 which is

03:29.325 --> 03:34.605
quite well greater than the value 4 that
is a maximum subscript possible for this

03:34.605 --> 03:39.885
array and for this situation one exception
will be raised and that's why we've

03:39.885 --> 03:51.207
written a catch block just following the tri block here and this catch block is handling
array index out of bounds exception and is a respective object for that and here

03:51.207 --> 03:54.767
we are having the remedial actions that
means we are printing one statement

03:54.767 --> 04:01.367
that is invalid index of the array okay
now next time we will define one string

04:01.367 --> 04:06.887
object string class object that is a my
string initialized with null and here

04:06.887 --> 04:14.927
in this particular system dot outer print element statement we're trying
to print the character at the fifth location but this my string has got

04:14.927 --> 04:20.087
initialized with null so if I want to pick
up the character from the fifth index of

04:20.087 --> 04:25.907
this particular my string object obviously
that will raise one exception so one

04:25.907 --> 04:30.047
exception will be produced and that's why
this particular code has been put within

04:30.047 --> 04:34.407
the tri block and immediately this code is
following the catch block and that is a

04:34.407 --> 04:39.987
null pointed exception e so system dot outd
printer length the string is pointing to

04:39.987 --> 04:46.487
to a null value. So, respective string, respective
message will get printed, which is the error handling part

04:47.387 --> 04:53.947
Okay, now see, here we are trying to convert
this ABC, this particular string, as an integer

04:54.607 --> 04:59.867
So now integer.d. Parse, I.N, B, C string,
which is not at all possible because
