Question: Question 13 import java.util.*; public class ExceptionExample1 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int dividend, divisor, quotient; try

Question 13

import java.util.*; public class ExceptionExample1 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int dividend, divisor, quotient; try { System.out.print("Enter dividend: "); dividend = console.nextInt(); System.out.println(); System.out.print("Enter divisor: "); divisor = console.nextInt(); System.out.println(); quotient = dividend / divisor; System.out.println("quotient = " + quotient); } catch (ArithmeticException aeRef) { System.out.println("Exception" + aeRef.toString()); } catch (InputMismatchException imeRef) { System.out.println("Exception " + imeRef.toString()); } catch( IOException ioeRef) { System.out.println("Exception " + ioeRef.toString()); } } } Which of the following inputs would be caught by the second catch block in the program in the accompanying figure?

0

10

h3

-1

1 points

Question 14

Which of the following is NOT a typical action of the catch block?

Completely handling the exception

Partially processing of the exception

Rethrowing the same exception for the calling environment

Throwing the exception

1 points

Question 15

What happens in a method if there is an exception thrown in a try block but there is no catch block following the try block?

The program ignores the exception.

The program will not compile without a complete try/catch structure.

The program terminates immediately.

The program throws an exception and proceeds to execute the finally block.

1 points

Question 16

Which of the following exceptions might be thrown by the methods of the class String?

NullPointerException

FileNotFoundException

NoSuchElementsException

NumberFormatException

1 points

Question 17

How many finally blocks can there be in a try/catch structure?

There must be one finally block.

There can be one finally block following each catch block.

There can be zero or one finally blocks following the last catch block.

There is no limit to the number of finally blocks following the last catch block.

1 points

Question 18

The class RuntimeException is the superclass of which of the following classes?

NullPointerException

NoSuchMethodException

IllegalAccessException

NoSuchFileException

1 points

Question 19

Which of the following statements is true?

The class Exception, which is derived from the class Object, is the superclass of the class Throwable.

The class Throwable, which is derived from the class Exception, is the superclass of the class Object.

The class Throwable, which is derived from the class Object, is the superclass of the class Exception.

None of these

1 points

Question 20

import java.util.*; public class ExceptionExample1 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int dividend, divisor, quotient; try { System.out.print("Enter dividend: "); dividend = console.nextInt(); System.out.println(); System.out.print("Enter divisor: "); divisor = console.nextInt(); System.out.println(); quotient = dividend / divisor; System.out.println("quotient = " + quotient); } catch (ArithmeticException aeRef) { System.out.println("Exception" + aeRef.toString()); } catch (InputMismatchException imeRef) { System.out.println("Exception " + imeRef.toString()); } catch( IOException ioeRef) { System.out.println("Exception " + ioeRef.toString()); } } } Which method throws the second exception in the code in the accompanying figure?

nextInt

toString

println

nextLine

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!