Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

image text in transcribed

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Find the integral of f@) 3C24x+5 between 2 and 3. x3 x2 -FTI

Answered: 1 week ago