Making an Exception

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

The string that was an argument to the constructor.

Making an Exception

There are two constructors for Exception:

Exception()

and

Exception( String str )

The string supplied to the second form can later be extracted from the object using its getMessage() method. Usually a method should construct and throw an exception all in one statement:

if ( some problem )
  throw new Exception("Informative Message" ) ;

QUESTION 12:

Since Exception is not a final class, can it be extended?