Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which class will not throw a compilation error if extended by adding a new checked exception to a method signature?

  1. A class that implements an interface

  2. A final class

  3. An abstract class

  4. None, adding a new checked exception is always an error

The correct answer is: An abstract class

Classes that implement an interface (A) will also throw a compilation error due to the need for the method to be implemented. Final classes (B) cannot be extended, so adding a checked exception to their method signature would not be possible. Abstract classes (C) allow for flexibility in method signatures and do not throw compilation errors when a new checked exception is added. Option D states that none of the classes will throw a compilation error, which is incorrect as stated in the question.