Mastering Java: The Ultimate Quiz for 'Thinking in Java

Question: 1 / 510

Why does Fill2 not require a Collection as Fill did?

Because it uses raw types instead of generic types

It uses reflection to dynamically call methods

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.

Get further explanation with Examzify DeepDiveBeta

Java 8 introduced default methods in interfaces

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy