Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 What can a method do with a checked exception? Check the exception or

ID: 3823617 • Letter: Q

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 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

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.

Explanation / Answer

Ans1) A method with a checked exception can "Throw the exception to the method that called this method, or handle the exception in a catch block".

Ans2)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 "WindowAdapter".

Ans3) "InputMismatchException" is the most likely type of exception in the code in the accompanying figure

Ans4) A message is returned by "getMessage()" method of an Exception object.

Ans5) RuntimeException class of exceptions is NOT checked.

Ans6) If a negative value is used for an array index,"an ArrayIndexOutOfBoundsException is thrown".

Thanks :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote