Exam 11: Handling Exceptions and Events

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

To handle window events, if the class containing the application program does not extend the definition of another class, you can make that class extend the definition of the class ____.

(Multiple Choice)
4.8/5
(42)

If a negative value is used for an array index, ____.

(Multiple Choice)
4.8/5
(37)

If you have created an exception class, you can define other exception classes extending the definition of the exception class you created.

(True/False)
4.7/5
(41)

int number; Boolean done = false;do { Try { System.out.print("Enter an integer: "); Number = console.nextInt(); System.out.println(); Done = true; System.out.println("number = " + number); } Catch (InputMismatchException imeRef) { Str = console.next(); System.out.println("Exception " + imeRef.toString() + " " + str); } } While (!done);What is the most likely type of exception in the code in the accompanying figure?

(Multiple Choice)
4.9/5
(37)

NoSuchElementException is a method of the class Exception.

(True/False)
4.8/5
(33)

The class Exception contains two constructors.

(True/False)
4.9/5
(45)

When an exception occurs, an object of a particular exception class is created.

(True/False)
4.7/5
(27)

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

(Multiple Choice)
4.7/5
(32)

int number; Boolean done = false;do { Try { System.out.print("Enter an integer: "); Number = console.nextInt(); System.out.println(); Done = true; System.out.println("number = " + number); } Catch (InputMismatchException imeRef) { Str = console.next(); System.out.println("Exception " + imeRef.toString() + " " + str); } } While (!done);How many times will the code in the try block in the accompanying figure execute?

(Multiple Choice)
4.8/5
(27)

An unchecked exception is any exception that causes a program to terminate.

(True/False)
4.8/5
(36)

Statements that might generate an exception are placed in a catch block.

(True/False)
4.8/5
(40)

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

(Multiple Choice)
4.8/5
(32)

A checked exception is any exception checked for by the programmer.

(True/False)
4.9/5
(31)

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 will cause the first exception to occur in the code in the accompanying figure?

(Multiple Choice)
4.8/5
(45)

The methods getMessage and printStackTrace are private methods of the class Throwable.

(True/False)
4.9/5
(33)

Which of the following statements is true?

(Multiple Choice)
4.8/5
(39)

If an exception occurs in a try block and that exception is caught by a catch block, then the remaining catch blocks associated with that try block are ignored.

(True/False)
4.8/5
(41)

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?

(Multiple Choice)
4.7/5
(27)

The JList GUI component generates events that call the actionStateChanged method.

(True/False)
5.0/5
(38)

A message is returned by which method of an Exception object?

(Multiple Choice)
4.8/5
(34)
Showing 21 - 40 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)