go to previous page   go to home page   go to next page

Answer:

Sure.


An Exceptional Child

A large application with several possible problem situations might define several subclasses of Exception.

Here is an example of an Exception child that could have been used with the example program.

Remember that super() in the constructor invokes the constructor of the super class, Exception. Now a method can throw a TooYoungException and a catch{} block can catch one.


public class TooYoungException extends Exception
{

  TooYoungException ( int age )
  {
    super( "Age is: " + age  );
  }

}

QUESTION 13:

Can child classes of Exception be thrown?


go to previous page   go to home page   go to next page