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

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

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

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.


What must be true for a class implementing an interface with a throws declaration?

  1. It must implement all methods defined in the interface

  2. It must throw at least one of the declared exceptions

  3. It can throw any subclass of RuntimeException

  4. It cannot throw checked exceptions not declared in the interface

The correct answer is: It cannot throw checked exceptions not declared in the interface

A class implementing an interface with a throws declaration must be able to handle or declare all checked exceptions that are defined in the interface. Option A is incorrect because implementation of all methods in the interface is not dependent on the throws declaration. Option B is incorrect because throwing an exception is not mandatory but handling or declaring is. Option C is incorrect because any subclass of RuntimeException is not required to be handled or declared. Therefore, option D is the most accurate answer as it correctly identifies what must be true for a class to implement an interface with a throws declaration.