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

1. A class that extends the KeyAdapter class would likely : override one or two

ID: 1812608 • Letter: 1

Question

1. A class that extends the KeyAdapter class would likely :

          

      override one or two of the KeyListener methods provided by KeyAdapter.
      also implement the KeyListener interface to handle KeyEvents.
      would let the KeyAdapter handle all KeyEvents.
      would not be interested in dealing with events from the keyboard.

2. A try block should contain:

           

     code which could possibly handle an exception.
      code which could possibly throw an exception.
      code which could possibly catch an exception.
      code which is not capable of throwing an exception.

3. In the catch block below, what is ArithmeticException?


   catch ( ArithmeticException arithmeticException )
   {
        System.err.printf( arithmeticException );
   }                                                           

     The type of the exception being caught.
      The name of catch block%u2019s exception parameter.
      A finally block.
      An exception handler.

4. When multiple exceptions can be thrown by several lines of code which are close together           

     the code should be placed in a single try block followed by multiple catch blocks for better readability.
      each line should be in a separate try block followed by a single catch block.
      each line should be contained in a separate catch block.
      this situation can never occur.

5. Which of the following creates a data stream for reading bytes from a file?           

     ByteInputStream stream = new ByteInputStream(%u201Cmyfile.txt%u201D);
      FileOutputStream stream = new FileOutputStream(%u201Cmyfile.txt%u201D);
      FileInputStream stream = new FileInputStream(%u201Cmyfile.txt%u201D);
      FileByteStream stream = new FileByteStream(%u201Cmyfile.txt%u201D);

Explanation / Answer

1. A class that extends the KeyAdapter class would likely : override one or two of the KeyListener methods provided by KeyAdapter. ==================================================================================================================================================================================================== A try block should contain: code which could possibly throw an exception =============================================================================================================================================================================================ArithmeticException? catch ( ArithmeticException arithmeticException ) { System.err.printf( arithmeticException ); } The type of the exception being caught. =============================================================================================================================================================================================