Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions