Question: (c) Answer question Q2(ei) to Q2(e)(v) in Figure Q2(e) below with suitable codes so that it can throw the exception. Line No Programming code 1

 (c) Answer question Q2(ei) to Q2(e)(v) in Figure Q2(e) below with

(c) Answer question Q2(ei) to Q2(e)(v) in Figure Q2(e) below with suitable codes so that it can throw the exception. Line No Programming code 1 // Program 02 (c) 2 import java.util.Scanner; 3 public class Final ExamException 4 public static void main(String[] args) { 5 // TODO code application logic here 6 int arr - 130, 4); 7 Scanner in - new Scanner (System.in); B 9 Q2 (c) (1) int b-in.nextInt () int x -arr121 / b - arr[i]); 1 UND onun 10 11 12 13 14 15 16 17 1B 19 20 21 22 23 24 25 26 27 28 catch Q2 (c) (ii) _ex) { System.out.printin ("Exceed array size"); 1 catch( Q2(c) (iii) _ex) System.out.println("Demonitor is zero"); 1 catch 02 (c) (iv) ex) { System.out.println("Invalid data:" +ex); 1 NNNNNN 02 (c) (v) inty - arr[11 / arr(01: System.out.println("y"+y); 1 Figure Q2(e): Program code (5 marks (d) Given program code Q2(d) as shown in Figure Q2(d), answer the following question. ) Explain why an error will occur when this program code is compiled. [2 marks] 6) Rewrite the program so that the program will compile and run properly. [3 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!