A good answer might be:

Yes.


Sample Output

Here is some sample output from the program. Different catch{} blocks catch the two different exceptions.

C:\chap81>java  IndexPractice
Enter the data:
8
Enter the array index:
10
This is your problem: 10
Here is where it happened:

java.lang.ArrayIndexOutOfBoundsException: 10
        at IndexPractice.main(IndexPractice.java:23)
Good-by

C:\chap81>java  IndexPractice
Enter the data:
Rats
This is your problem: Rats
Here is where it happened:

java.lang.NumberFormatException: Rats
        at java.lang.Integer.parseInt(Integer.java:409)
        at java.lang.Integer.parseInt(Integer.java:458)
        at IndexPractice.main(IndexPractice.java:18)
Good-by

A more sensible program would use a loop to collect data from the user and place it in the array, and then process the array somehow.

QUESTION 4:

What does the "18" mean in

at IndexPractice.main(IndexPractice.java:18)