Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 6 7 8 9 le 11 12 13 14 In the Code below, you are given a java class X, which contains a throwlt()

image text in transcribed

5 6 7 8 9 le 11 12 13 14 In the Code below, you are given a java class X, which contains a throwlt() method and a main method. The main method reads a value from the user, converts it into an integer and then uses it to call the throwlt() method. Decide whether the answers below are correct or not. Write a short explanation as to why. (Unjustified or incorrectly justified answers will not be accepted.) 1 import java.util.Scanner; 2 3 public class X{ public static void throwIt(int input) throws Exception { if (input == 1) throw new RuntimeException(); else if (input == 2) return; else if (input == 3) { int x = ; int y = 5 / x; } else if (input == 4) throw new Exception(); } 15 16e public static void main(String[] args) { try { Scanner scan = new Scanner(System.in); int value = Integer.parseInt(scan.next(); throwit(value); } catch (Number FormatException ne) { 22 System.out.print("Not valid "); } catch (ArithmeticException ae) { System.out.print(" Arithmetic Exception "); } catch (Exception re) { System.out.print("caught "); } finally { System.out.print("finally "); 29 } System.out.println("after"); } 32 } 7 * A B 1 = = 17 18 19 20 21 23 24 25 26 27 28 30 31 *** Don't delete the questions. Please only write your answers. *** a) If the program is executed with parameter "1", the output will be "finally after". b) If the program is executed with parameter "2", the output will be "finally after": c) If the program is executed with parameter "Not_a_number", the execution of the program stops printing an error message after printing "Not valid finally after d) If the program is executed with parameter "3", the output will be "Arithmetic Exception after". le) If the program is executed with parameter "4", the output will be "caught finally after

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago