Sure.
A large application with several possible problem situations might
define several subclasses of Exception
.
public class TooYoungException extends Exception { TooYoungException ( int age ) { super( "Age is: " + age ); } }
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.
Have you just thrown a BoredSillyException
?