Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IT-162 Java 2 Homework: Exception Handling Apply your knowledge of handling exceptions in Java. Submit the project.zip via Blackboard. Create a program that creates exceptions.

IT-162 Java 2

Homework: Exception Handling

Apply your knowledge of handling exceptions in Java. Submit the project.zip via Blackboard.

Create a program that creates exceptions.

Create Java project Week03Exceptions. Create TestExceptions.java to demonstrate exceptions in Java.

TestExceptions.java must have the following methods: main, TestArithmeticError, TestArrayIndexError, TestNumbeFormatError, TestStringIndexError, and TestNullPointerError. (50 points)

main: This calls other methods.

TestArithmeticError: Test dividing a number by zero. Initialize intNum1 and intNum2 respectively to 30 and zero. Declare output to be equal to intNum1 / intNum2. Catch division by zero and display message You should not divide a number by zero.

TestArrayIndexError: Test accessing an array index which does not exist. For example, if an array has only 5 elements and we are trying to display 7th element then it would throw this exception. The exception message should display Array Index Out of Bounds.

TestNumberFormatError: Test parsing a string to any numeric variable using Integer.parseInt. It will throw NumberFormatException since a string cannot be parsed to int. Display exception message Number format exception occurred.

TestStringIndexError: Test for an index that is not within the range. Each character of a string object is stored in a particular index starting from 0. Use method charAt(intIndex) of java.lang.String where intIndex argument is the index. Display exception message String Index Out of Bound Exceptions.

TestNullPointerError: Test for a null object using str.length. Display exception message Null Pointer Exception.

Be sure the program checks for other error processing as necessary. (10 points)

The program must follow proper naming conventions of this course. (10 points)

Test the program and provide a print-screen of the test results. (10 points)

Be sure to have the proper program documentation/comments. All methods must have the proper JavaDoc comments. (10 points)

Generate a JavaDoc for your Project. You do this by selecting your project folder, select Project, Generate JavaDoc. You can refresh your project to see the doc folder that contains your index.html. Select Open With, Web Browser, navigate to annotations and provide a print-screen with your submission. (10 points)

Refer to the practice exercise for tips on how to create this application.

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

15.6. Describe the meaning of Figure 15.4 in your own words.

Answered: 1 week ago