Question: Question 1 What can a method do with a checked exception? Check the exception or ignore it. Return the exception to the sender or handle
Question 1
What can a method do with a checked exception?
| Check the exception or ignore it. | ||
| Return the exception to the sender or handle it in a catch block. | ||
| Throw the exception to the method that called this method, or handle the exception in a catch block. | ||
| Handle the exception in the try block or handle the exception in the catch block. |
1 points
Question 2
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 ____.
| MouseAdapter | ||
| Adapter | ||
| WindowAdapter | ||
| WindowListener |
1 points
Question 3
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?
| IllegalArgumentException | ||
| InputMismatchException | ||
| FileNotFoundException | ||
| NumberFormatException |
1 points
Question 4
A message is returned by which method of an Exception object?
| printMessage() | ||
| getMessage() | ||
| printStackTrace() | ||
| traceMessage() |
1 points
Question 5
Which class of exceptions is NOT checked?
| FileNotFoundException | ||
| ArithmeticException | ||
| RuntimeException | ||
| All exceptions are checked. |
1 points
Question 6
If a negative value is used for an array index, ____.
| a NumberFormatException is thrown | ||
| the program terminates automatically without throwing an exception | ||
| the last index of the array is automatically accessed instead | ||
| an ArrayIndexOutOfBoundsException is thrown |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
