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

Mention the default values of all the elements of an array defined as an instance variable.

763


Can I overload to string method

1199


Can you tell me range of byte?

779


How an object is serialized in java?

767


What is try-with-resources in java?

881


What are the features of junit?

842


What is argument in java?

795


What is protected access modifier?

824


What is polymorphism in java? What are the kinds of polymorphism?

836


how to deploy apache tomcat server to weblogic server in java

1822


What is use of super keyword?

763


How does linkedhashmap work in java?

727


What is finalize method?

850


Can we sort hashmap in java?

755


What is matcher in java?

753