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.


Why does Fill2 not require a Collection as Fill did?

  1. Because it uses raw types instead of generic types

  2. It uses reflection to dynamically call methods

  3. It only requires an implementer of an Addable interface

  4. Java 8 introduced default methods in interfaces

The correct answer is: It only requires an implementer of an Addable interface

Unlike the original Fill method, Fill2 only requires an implementer of the Addable interface because it was specifically designed to work with custom objects that implement this interface. Option A is incorrect because raw types are not used in Fill2; it uses generics as well, just in a different way. Option B is incorrect because Fill2 does not use reflection, it instead relies on the methods defined in the Addable interface. Option D is incorrect because the use of default methods in interfaces is not related to the reason why Fill2 does not require a Collection.