Question: (This question carries 6 marks) Q) Write a class InvalidCNICException that extends Exception class. The class should have following details implemented A message property. override
(This question carries 6 marks)
Q) Write a class InvalidCNICException that extends Exception class.
The class should have following details implemented
A message property.
override following method that returns message
String toString()
Two constructors
1. With no parameter
2. With String parameter
Take user input for CNIC. The CNIC is considered valid if
1. The length of CNIC is 15(including -)
2. if the hyphen(-) is present at position 6 and 14.
Generate (throw) InvalidCNICException when an invalid CNIC has been entered by the user. Handle this exception by giving user a responsive message saying "The CNIC you entered is not valid.
NOTE: Code should be in Java (Object oriented programming) and use eclipse to solve. Attach the output of console and also attach the code written on eclipse.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
