top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is a Java Exception and what are the five keywords used in Java Exception handling?

+2 votes
293 views
What is a Java Exception and what are the five keywords used in Java Exception handling?
posted Feb 6, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Exception is exception and definition is same in all languages -

An exception is an abnormal condition that arises in a code sequence at run time.In other words,an exception is an event,which occurs during the execution of a program, that disrupts the normal flow of the program.When an exception is thrown,an object of a particular exception subtype is instantiated and handed to the exceptional handler as an argument to the catch clause.An actual catch clause as shown below-

try { 
// some code here
}
catch (ArrayIndexOutOfBoundException e) {
 e.printStackTrace();
}

In this example,e is an instance of the ArrayIndexOutOfBoundExceptionclass.As with any other object,we can call its methods.

In Jave we have these five keywords which are used in Exception handling:

  1. try
  2. catch
  3. finally
  4. throw
  5. throws
answer Feb 6, 2015 by Salil Agrawal
...