Home > Java > javaTutorial > body text

Chapter 9 Final Tests

Linda Hamilton
Release: 2024-10-30 07:10:28
Original
479 people have browsed it

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
 }
Copy after login
  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) { ... }
Copy after login
  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();
Copy after login
  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!

source:dev.to
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!