• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Exceptions.....

 
Manoj Mani
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)..
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic