C# Unit 11

  1. Any error condition or unexpected behavior in an executing program is known as an ________.




    B. exception
  2. Which of the following is not treated as a C# Exception?




    A. You attempt to execute a C# program, but the C# compiler has not been installed.
  3. Most exceptions you will use derive from three classes: _____.




    A. Exception, SystemException, and ApplicationException
  4. Exception objects can be ______.




    B. both of these
  5. When a program creates an Exception object, you ______.




    A. can handle it
  6. If you do not use object-oriented techniques, _________.




    A. you can still manage error situations
  7. In object-oriented terminology, you ______ a procedure that might not complete correctly.




    D. try
  8. In object-oriented terminology, a method that detects an error condition _____ an exception.




    B. throws
  9. When you write a block of code in which something can go wrong, and you want to throw an exception if it does, you place the code in a _______ block.




    A. try
  10. A catch block execute when its try block ______.




    C. throws an Exception of an acceptable type
  11. Which of the following catch blocks will catch any Exception object?




    B. catch(Exception e) {}
  12. Which of the following is valid within a catch block with the header catch(Exception error)?




    C. two of these
  13. You can place _____ statement(s) within a try block.




    C. any number of
  14. How many catch blocks might follow a try block within the same method?




    B. any number, including zero or one
  15. Consider the following try block. If x is 15, what is the value of a when this code completes?

      try
      {
        a = 99;
        if(x > 10)
           throw(new Exception());
        a = 0;
        ++a;
       }




    B. 99
  16. Consider the following catch blocks. The variable b has been initialized to 0. If a DivideByZeroException occurs in a try block just before this catch block, what is the value of b when this code completes?

       catch(DivideByZeroException e)
       {
          ++b;
        }
         catch(Exception e)
        {
           ++b;
         }




    A. 1
  17. Consider the following catch blocks. The variable c has been initialized to 0. If an IndexOutOfRangeException occurs in a try block just before this catch block, what is the value of c when this code completes?

         catch(IndexOutOfRangeException e)
         {
            ++c;
          }
          catch(Exception e)
          {
             ++c;
           }
           finally
           {
              ++c;
           }




    C. 2
  18. If your program throws an IndexOutOfRangeException, and the only available catch block catches an Exception, _______.




    A. the Exception catch block executes
  19. When you design your own classes that might cause exceptions, and other classes will use your classes as clients, you should usually create your methods to ________.




    B. throw exceptions but not handle them
  20. When you create an Exception subclass of your own, you should extend the _______ class.




    C. Exception
Author
jdavis123
ID
358671
Card Set
C# Unit 11
Description
Updated