Practice Programs Exceptions
Practice Programs Exceptions
1. A method that returns a special error code can sometimes cause problems. The
caller might ignore the error code or treat the error code as a valid return value. In
this case it is better to throw an exception instead. The following class maintains
an account balance and returns a special error code.
2. Write a Java program to create a method that takes a string as input and throws
an exception if the string does not contain vowels.
3. Write a program that allows the user to compute the remainder after the division
of two integer values. The remainder of x / y is x % y. Catch any exception thrown
and allow the user to enter new values.