All right.
So in this video I want to show you what happens if you don't have this catch exception block here.
And you get an exception that you didn't catch.
So we have these different exceptions here.
Divide by zero format exception overflow exception.
So now let's get rid of this exception here.
And also of the overflow exception I'm going to comment those lines out okay.
So they will not be compiled.
Now let me run this and show you what I mean.
So let's say I want to overflow here again.
And there we are.
Now our application is crashing.
Why is it crashing?
Well, because our overflow exception wasn't handled.
Okay, now let me show you what happens if we uncomment the exception here and we do it like this?
Let's run it again.
Now let me overflow again.
And we see.
We display it displays the overflow exception for us, but our application still runs.
So it executes.
It displays the result so it doesn't crash.
That's because this default exception is really, really powerful.
It just manages all other kinds of exceptions that we didn't specifically catch.
So we specifically called divide by zero.
We specifically called format exception.
But we didn't specifically catch the overflow exception because we commented it out.
So the exception here, this default exception will manage all other types of exceptions that there
are.
Now this specific exception catching that we did in the last video is still useful.
It's useful when you actually want to execute a specific code if a specific exception occurs.
Okay, so what happens if I comment this line out but leave the overflow exception in.
So I uncomment this.
Well then in our overflow example it will just catch the error and everything will work fine.
But now we are not catching any error that we didn't think of because we said okay, we don't need you
boss or mom.
Uh, that's what this exception here is, because it is the parent exception of all other exceptions.
Let me show you what I mean with this.
And this will make a lot more sense once we get into inheritance.
So if you click into the overflow exception with holding the control key or command on Mac or on the
Mac, you can see that there is this class called Overflow exception.
But then something weird comes after that.
You see, there comes this colon and then it says arithmetic exception.
Now let's press the control key and click into arithmetic exception and we will see again it says public
class.
And then there's this arithmetic exception.
But then it inherits from something called system exception.
So this colon here means it inherits.
Now let's look at the system exception.
And it's again a class that this time inherits from exception.
So in order to even get to our overflow exception we need multiple layers of exceptions that we need
to go through in order to even get to the final mother exception.
So basically, it's not the mother exception of the overflow exception.
I think it's the grand, grand, grand mother or so because with multiple layers of inheritance there.
So as I said, don't worry about it for now.
We're going to cover inheritance in a lot more depth.
But this was just a little, let's say peek preview, sneak peek I think sneak peek into what exceptions
are.
And it will be a lot more fun to see what inheritance is, so it will make a lot more sense to look
at the inheritance chapter, which we're going to cover, I believe, next as the next chapter or maybe
a few later.
So that's it for this video.
Don't forget to thank your mother.
Actually, yesterday was Mother's Day, at least in Germany, so don't forget to thank your mother exception
and see you in the next video.