Super Class Examples of Exception
HELP!!!
I'm in need of assistance. I do not get Super classes and really how they work. Our book goes into such detail, it doesn't really give us a little example to work from for understanding. So here is a question: I need is Use Inheritance to create an exception class (ExceptionA) which is the super class, then subclasses ExceptionB class and ExceptionC class which both B and C classes inherit from A. We are suppose to write a program to catch block for type ExceptionA catches exceptions of types ExceptionB and ExceptionC.
I can't grasp the concept of how to put these together. I'm not sure where the main method fits in all of these and does each have a try/catch that calls something from ExceptionA?
[736 byte] By [
SkyeyesPPa] at [2007-11-27 11:29:07]

Ok..I'm just looking for help, yes an ANSWER to how to utilize (1) inheritance and then (2) to incorporate that into my homework. For example, I have an ExceptionA Class super, a subclass ExceptionB and a subclass ExceptionC. I'm really lost as to where do I put the main method. I have 3 methods, where do I put these and how do I call them. Does anyone have a little snippet of code that shows very basically a super class, a subclass that calls the superclass, and another subclass that calls the superclass and where the main fits in all of that. Below is all my code.
* Figure 13.17 Catching Exceptions with Superclasses
package Dialogs;
//superclass Exception
public class ExceptionA
{
//start of main method
public static void main( String args[] )
{
try
{
//call method one
one();
}
catch ( Exception exception )
{
exception.printStackTrace();
}//end of try/catch for main
} //end main method
}//end of ExceptionA
**********************************************************************
package Dialogs;
public class ExceptionsB extends ExceptionA
{
// exceptions back to main with one
public static void one() throws Exception
{
try
{
//call method two
two();
} // end try
catch ( Exception exception )
{
throw new Exception( "Exception in one", exception );
} // end try/catch for method one
} // end method one
}//end of class ExceptionsB
**************************************************************************
package Dialogs;
public class ExceptionC extends ExceptionA
{
// two method throws back to one
public static void two() throws Exception
{
try
{
//call method 3
three();
}
catch ( Exception exception )
{
throw new Exception( "Exception in two", exception );
} // end of try/catch two
} // end method 2
// throws Exception back to two
public static void three() throws Exception
{
throw new Exception( "Exception in three" );
} // end method 3
}