Computer Education Introduction to Computer Science Using Java™ Computer Education Introduction to Computer Science Using Java™   Glencoe Online
Computer Education Home Product Information Site Map Search Contact Us

Students

Self-Assessment Exercises

Chapter 15: Exceptions
      
  1.What happens when a Java program executes the following statement?

x = 100 / 0;
 
  a.   An ArithmeticException is thrown.  
  b.   The program terminates with a somewhat helpful message.  
  c.   x is assigned 0.  
  d.   x is assigned infinity.  
      
  2.All exceptions ultimately derive from the ________ class.  
  a.   Error  
  b.   Exception  
  c.   Throwable  
  d.   UserException  
      
  3.Which of the following catch statements would catch a DivideByZeroException ?  
  a.   catch (ArithmeticException e) { … }  
  b.   catch (DivideByZeroException e) { … }  
  c.   catch (Exception e) { … }  
  d.   All of the above  
      
  4.Once an exception is caught, it ________.  
  a.   may be rethrown with a rethrow statement  
  b.   may be rethrown with a throw statement  
  c.   may be rethrown with a throws statement  
  d.   must be handled and cannot be rethrown  
      
  5.The finally keyword is used to identify a block of code that ________.  
  a.   is constant  
  b.   must be run just before the program exits  
  c.   must be run just before the program throws an exception  
  d.   must be run before the method exits  

 

McGraw-Hill Glencoe   The McGraw-Hill Companies
Self-Assessment Exercises
Java Compilers
Source Code
Java Resources
PowerPoint® Presentations
Home