File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Exceptions..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in Exceptions....." Watch "Doubt in Exceptions....." New topic
Author

Doubt in Exceptions.....

Manoj Mani
Ranch Hand

Joined: Mar 31, 2007
Posts: 65
class Apple
{
public void m1() throws SecurityException
{
System.out.println("I want more apple");
}
}


public class Orange extends Apple
{
public void m1() throws SecurityException
{
System.out.println("I want more Orange");
}
public static void main(String [] args)
{
Orange p = new Orange();
p.m1();
}
}


Now if we change SecurityException either by IOException,Exception etc...we will get an error... Can anybody give the complete hierarchy of the Checked,Unchecked Exceptions(Better,give the complete hierarchy starting from Throwable)..


Impossible Is Often Untried.Its Time For Us To Change....
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
There are hundreds of exceptions and for exam absolutely not necessary to know them all. If it really matters which exception inherits Exception class and
which specifically inherits RuntimeException exam will surly tell us except
the exceptions we must know. I can give you the listings of them:





exceptions that directly extend from exception
--------------------------------------------------------------------
1- InterruptedException
2- IOException
3- FileNotFoundException extends IOException
4- EOFException extends IOException extends Exception
5- ClassNotFoundException


exceptions that directly extend from RuntimeException (we need to know)
----------------------------------------------------------------------------------------------------------
1- IllegalArgumentException
2- IllegalStateException
3- IllegalMonitorStateException
4- NullPointerException
5- ClassCastException
6- NumberFormatException extends IllegalArgumentException extends RuntimeException and so on ...
7- ArrayIndexOutOfBoundsException extends IndexOutputBoundsException extends RuntimeException
8- StringIndexOutOfBoundsException extends IndexOutOfBoundsException extends RuntimeException
9- UnSupportedOperationException
10- ConcurrentModificationException
11- IllegalFormatConversionException extends IllegalFormatException extends IllegalArgumentException extends RuntimeException
12- IllegalFormatPrecisionException extends IllegalFormatException extends IllegalArgumentException extends RuntimeException
13- UnknownFormatConversionException extends IllegalFormatException extends IllegalArgumentException extends RuntimeException
14- MissingFormatWidthException extends IllegalFormatException extends IllegalArgumentException extends RuntimeException

Errors we need to know: (extend from Error)
1- AssertionError
2- ExceptionInInitializerError extends LinkageError extends Error and so on
3- StackOverflowError extends java.lang.VirtualMachineError extends java.lang.Error
4- NoClassDefFoundError extends java.lang.LinkageError extends java.lang.Error



Did I miss any Exception?


Regards,
cmbhatt


cmbhatt
Tina Tibrewal
Ranch Hand

Joined: Apr 19, 2007
Posts: 40
This is from complete reference:

Unchecked Exceptions:
ArithmeticException
ArrayIndexOutOfBoundsException
ArrayStoreException
ClassCastException
IllegalArgumentException
IllegalMonitorStateException
IllegalStateExceptionIllegalThreadStateException
IndexOutOfBoundsException
NegativeArraySizeException
NullPointerException
NumberFormatException
SecurityException
StringIndexOutOfBounds
UnsupportedOperationException

Checked Exception

ClassNotFoundException
CloneNotSupportedException
IllegalAccessException
InstantiationException
InterruptedException
NoSuchFieldException
NoSuchMethodException

Hope that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Exceptions.....