Question: Given the following program: import java.util.*; public class Main { public static void main(String[] args) { int num=0; for (int i=0; i
Given the following program:
import java.util.*;
public class Main { public static void main(String[] args) { int num=0;
for (int i=0; i <= args.length -1; i++) { try{ int denom=Integer.parseInt(args[i]);
System.out.println(num + / + denom + = + (num/denom));
num=denom;
} catch(ArithmeticException e) { System.out.println(division by zero);
} catch(ArrayIndexOutOfBoundsException e) { System.out.println(Index out of bonds);
} } System.out.println(End of the program.);
} }
What is the output if you run the program using:
java Main 0 1
- N.A.
- 0/1 = 0
Division by zero
End of the program.
- 0/1 = 0
End of the program.
- Division by zero
0/1 = 0;
End of the program.
- Division by zero
0/1 = 0
Index out of bonds
End of the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
