Question: Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the first character of the string

Create a class called ExceptionPractice which includes a main method. The program asks user to enter a string. If the first character of the string is not a letter, it throws an InvalidStringException. The program handles the exception by printing an error message and exiting the program. Otherwise, it converts the first character into Uppercase (without changing the rest of the characters) and print the new string. You also need to write a class for InvalideStringException. It should extend the Exception class. You need to include two constructors, the default constructor and a one-parameter constructor (for which the parameter type is String). Include the code for both ExceptionPractice class and InvalidStringException class below.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!