Question: ramm Task 27: Defining Custom Exception Class. Aim: To define a Custom Exception. Title: Person, Illegal PersonException and Test classes. Summary: You can define a

 ramm Task 27: Defining Custom Exception Class. Aim: To define a

ramm Task 27: Defining Custom Exception Class. Aim: To define a Custom Exception. Title: Person, Illegal PersonException and Test classes. Summary: You can define a custom exception class by extending the Exception class. Question: In this task, create a Person class of three attributes name, age, and city. In our program, any person his/her age must be greater than or equal 18. The defined Person class must follow to this rule. To do that, let the constructor throws a custom exception named illegalPersonException object if a person is created with age that violate the rule. Also, write a test Java program that create an object of type Person by asking the user to enter the name, age and city. Your program should prompt the user to read the name, age, and city again if the input is incorrect

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!