The program illustrates the use of catching exceptions using try and catch.
The required try and catch block is as follows:
try {
System.out.print(names[index]);
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println(e.getMessage());
}
The flow of the above code segment is as follows:
First, we begin with the try block
try {
Then the program prints the element at the index
System.out.print(names[index]); }
If the index does not exist in the array (e.g. -1 or 11), then the catch block is executed
catch (ArrayIndexOutOfBoundsException e) {
This prints the appropriate exception
System.out.println(e.getMessage()); }
See attachment for sample run
Read more about similar programs at:
https://brainly.com/question/21330187