Question: 3. What is the output of the program below, state if there will be an exception? If so, state what type is it, and show
3. What is the output of the program below, state if there will be an exception? If so, state what type is it, and show how to handle it. class Class1 { public static void main(String args[]) { int total = 0; int[] i = new int[3]; for(int j=1;j<= i.length; j++) total += (i[j] = j); System.out.println(total); } } 4. What is the output of the program below: try { int values[] = {1,2,3,4,3,2,1}; for (int i = values.length-1; i >= 0; i++) System.out.print( values[i] + " " ); } catch (Exception e) { System.out.print("2" + " "); } finally { System.out.print("3" + " "); }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
