<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
public class ExceptionDemo1 {

 public static void main(String[] args) {
  //TODO: In each catch statement, modify the print statement to include a message
  // to explain why the exception was thrown.
  //TODO: For each try-catch block, modify the code as needed so that no Exceptions
  // are thrown/caught.

  try {
          int num1= 30, num2= 0;
          int output= num1/num2;
          System.out.println ("Result = " +output);
     } catch (ArithmeticException e) {
          System.out.println ();
     }

  try {
         int a[]= new int[10];
         a[11]= 9;
         System.out.println("Array element" + a[15]);
     } catch (ArrayIndexOutOfBoundsException e) {
          System.out.println ();
     }

  try {
   String str= null;
   String str1= str;
   System.out.println("Length of string: " + str1.length());
  } catch (NullPointerException e) {
   System.out.println();
  }

  try {
   String str= "CS2110 is a great class.";
   char c= str.charAt(0);
   c= str.charAt(30);
   System.out.println(c);
  } catch (StringIndexOutOfBoundsException e) {
   System.out.println();
  }
 }
}
</pre></body></html>