Question: Create a user defined exception InvalidAgeException by extending the java Exception class. The method prototype is given as validate(int age) throws InvalidAgeException. If the age

 Create a user defined exception InvalidAgeException by extending the java Exception

Create a user defined exception InvalidAgeException by extending the java Exception class. The method prototype is given as validate(int age) throws InvalidAgeException. If the age of a person is less than 18 years throw an exception and prints Exception occurred: Candidate is less than 18 year is not allowed to vote. Otherwise print "rest of the code

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 Databases Questions!