What are different types of Exceptions?.

Answer Posted / gagan jain

common exceptions:
Java has several predefines exceptions. the most common
exceptions that you may encounter are described below.

Arithmetic Exception:-
This exception is thrown when an exceptional arithmetic
condition has occurred. for example, a division by zero
generates such an exception.

Nullpointer Exception:-
This exception is thrown when an application attempts to
use null where an object is required. An object that has
not been allocated memory holds a null value. the
situations in which an exception is thrown include:
1. Using an object without allocating memory for it.
2. Calling the methods of a null object.
3. Accessing or modifying the attributes of null obect.

ArrayIndexoutof Bounds Exception
The exception Arrayindexoutofbounds Exceptions is thrown
when an attempt is made to access an array element beyond
the index of the array. for example, if you try to access
the eleventh element of an array that's has only ten
elements, the exception will be thrown.

Is This Answer Correct ?    16 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a parameter in java?

746


How would you use Bubble Sort to sort the number of elements?

822


What happens when you invoke a thread’s interrupt method while it is sleeping or waiting?

773


What are the 7 types of characters?

845


What is the use of conditional statement?

752


Which collection is sorted in java?

795


How to set the permissions to a file in java?

763


Is java hashset ordered?

822


Is overriding possible in java?

712


What do you mean by an object in java?

877


What methods are used to get and set the text label displayed by a button object?

786


What is the return type of the main method?

802


Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyall() methods are executed?

857


What is the purpose of file class?

763


How do I remove a character from a string in java?

721