Answered You can hire a professional tutor to get the answer.

QUESTION

Please look over and construct a solution for #1 and #2 public static void main(String args){ int a,b,c; // We define variables of type integer...

Please look over and construct a solution for #1 and #2

   public static void main(String args[]){

       int a,b,c;      // We define variables of type integer namned a, b, and c.

       try {         // We set up the try check block. We will be looking for an invalid value for integer c

            a=0;      // Now we assign values to the variables.

            b=15;

            c=b/a;      // The result of dividing a number by 0 is undefined. Exception!

            System.out.println("This line will not be executed when a=0 because when a=0, the previous line throws an exception to the catch block.");     

       }

       catch(ArithmeticException e) { // As soon as an exception is thrown in the "try" block, execution of this code begins.

            System.out.println("Catching this exception thrown by the try block: " + e);

       }

      System.out.println("Execution resumes here after both the try and catch blocks execute.");

   }

  1. What are the results of the program as written?
  2. What results would the program produce if you changed the value of a from 0 to 3?
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question