Home  >  Article  >  Java  >  Chapter 9 Final Tests

Chapter 9 Final Tests

Linda Hamilton
Linda HamiltonOriginal
2024-10-30 07:10:28480browse

Testes Finais do Capítulo 9

  1. Which class sits at the top of the exception hierarchy?
  2. Briefly explain how try and catch are used.
  3. What's wrong with this fragment?
 // ...
 vals[18] = 10;
 catch (ArrayIndexOutOfBoundsException exc) {
  // trata erro
 }
  1. What happens when an exception is not caught?
  2. What's wrong with the following fragment?
 class A extends Exception { ...
 class B extends A { ...
 // ...
 try {
  // ...
 }
 catch (A exc) { ... }
 catch (B exc) { ... }
  1. Can an internal catch rethrow an exception for an external catch?
  2. The finally block is the last piece of code executed before the program has undermine. Is this true or false? Explain your answer.
  3. What type of exceptions should be explicitly declared in the throws clause of a method?
  4. What's wrong with this fragment?
 class MyClass { // ... }
 // ...
 throw new MyClass();
  1. In Question 3 of the Chapter 6 Test, you created a Stack class. Add custom exceptions to your class that report stack full and stack empty conditions.
  2. What are three ways an exception can be thrown?
  3. What are the two direct subclasses of Throwable?
  4. What is multi-catch feature?
  5. Normally, code should catch Error type exceptions?

The above is the detailed content of Chapter 9 Final Tests. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn