Question: Write a program that declares an array of numbers. The array should have the following numbers in it 7,8,9,10,11. Do this in the main method.

Write a program that declares an array of numbers. The array should have the following numbers in it 7,8,9,10,11. Do this in the main method. Make a method called printArray. This will return nothing, so it should be a void type method. Then make a for loop that looks like this for(int i=0; i < 10; i++). Iterate through the array of numbers and print out each number with println(). If you do this properly you should get an error when your program runs. You will generate an array index out of bounds exception. You need to add exception handling to your program so that you can catch the index out of bounds exception and a normal exception. When you catch the exception just print you caught it. You also need to have a finally section in your try/catch block.

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!