The main advantages of the exception-handling mechanism in object oriented programming over the traditional error-handling mechanisms are the following:
• The separation of error-handling code from normal code unlike traditional programming languages, there is a clear-cut distinction between the normal code and the error-handling code. This separation results in less complex and more readable (normal) code. Further, it is also more efficient, in the sense that the checking of errors in the normal execution path is not needed, and thus requires fewer CPU cycles.
• A logical grouping of error types Exceptions can be used to group together errors that are related. This will enable us to handle related exceptions using a single exception handler. When an exception is thrown, an object of one of the exception classes is passed as a parameter. Objects are instances of classes, and classes fall into an inheritance hierarchy in Java. This hierarchy can be used to logically group exceptions. Thus, an exception handler can catch exceptions of the class specified by its parameter, or can catch exceptions of any of its sub-classes.
• The ability to propagate errors up the call stack Another important advantage of exception handling in object oriented programming is the ability to propagate errors up the call stack. Exception handling allows contextual information to be captured at the point where the error occurs and to propagate it to a point where it can be effectively handled. This is different from traditional error-handling mechanisms in which the return values are checked and propagated to the calling function.
The following is a list of exceptions under the Throwable class:
Throwable
Error
AWTError
LinkageError
ClassCircularityError
ClassFormatError
Exception InInitializerError
IncompatibleClassChangeError
NoClassDefFoundError
UnsatisfiedLinkError
VerifyError
ThreadDeath
VirtualMachineError
InternalError
OutOfMemoryError
StackOverflowError
UnknownError
Exception
AclNotFoundException
ActivationException
UnknownGroupException
UnknownObjectException
AlreadyBoundException
ApplicationException
AWTException
BadLocationException
ClassNotFoundException
CloneNotSupportedException
ServerCloneException
DataFormatException
ExpandVetoException
FontFormatException
GeneralSecurityException
CertificateException
CRLException
DigestException
InvalidAlgoorithmParameterException
InvalidKeySpecException
InvalidParameterSpecException
Key Exception
KeyStoreException
NoSuchAlgorithmException
NoSuchProviderException
SignatureException
UnrecoverableKeyException
IllegalAccessException
InstantiationException
IntrospectionException
InvalidMidiDataException
InvocationTargetException
IOException
ChangedCharSetException
CharConversionException
EOFException
FileNotFoundException
Interrupted 0 Exception
MalformedURLException
ObjectStreamException
ProtocolException
RemoteException
SocketException
SyncFailedException
UnknownHostException
UnknownServiceException
UnsupportedEncodingException
UTFDataFormatException
ZipExcept
LastOwnerException
LineUnavailableException
MidiUnavailableException
MimeTypeParseException
NamingException
AttributeInUseException
ArtributeModificationException
CannotProceedException
CommunicationException
ConfigurationException
ContextNotEmptyException
InsufficientResourcesException
InterruptedNamingException
InvalidAttributeldentifierException
InvalidAttributesException
InvalidAttributeValueException
InvalidNameException
InvalidSearchControlsException
InvalidSearchFilterException
LimitExceededException
LinkException
NameAlreadyBoundException
NameNotFoundException
NamingSecurityException
NoInitialContextException
NoSuchAttributeException
NotContextException
OperationNotSupportedException
ReferralException
Schema ViolationException
ServiceUnavailableException
NoninvertibleTransformException
NoSuchFieldException
NoSuchMethodException
NotBoundException
NotOwnerException
ParseException
PartialResultException
PrinterException
PrinterAbortException
PrinterIOException
PrivilegedActionException
RemarshalException
RuntimeException
ArithmeticException
ArrayStoreException
CannotRedoException
CannotUndoException
ClassCastException
CMMException
ConcurrentModificationException
EmptyStackException
IllegalArgumentException
IllegalMonitorStateException
IllegalPathStateException
IllegalState Exception
ImagingOpException
IndexOutOfBoundsException
MissingResourceException
NegativeArraySizeException
NoSuchElementException
NullPointerException
ProfileDataException
ProviderException
RasterFormatException
SecurityException
SystemException
UndeclaredThrowableException
UnsupportedOperationException
SQLException
BatchUpdateException
SQLWarning
TooManyListenersException
UnsupportedAudioFileException
UnsupportedFlavorException
UnsupportedLookAndFeelException
UserException
AlreadyBound
BadKind
Bounds
CannotProceed
InconsistentTypeCode
Invalid
InvalidName
InvalidName
InvalidSeq
InvalidValue
NotEmpty
NotFound
PolicyError
TypeMismatch
UnknownUserException
WrongTransaction