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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started