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 is the difference between List<Apple> and List<? extends Fruit>?

  1. List<Apple> can contain any type of Fruit

  2. List<? extends Fruit> specifies a List of any type that extends Fruit

  3. List<Apple> and List<? extends Fruit> are the same

  4. There is no difference, it's a matter of syntax

The correct answer is: List<? extends Fruit> specifies a List of any type that extends Fruit

List<Apple> specifies a List that can only contain Apple objects, while List<? extends Fruit> specifies a List that can contain any type of Fruit (including Apple). Option A is incorrect because List<Apple> can only contain Apple objects, not any type of Fruit. Option C is incorrect because List<Apple> and List<? extends Fruit> have different specifications. Option D is incorrect because there is a clear distinction between List<Apple> and List<? extends Fruit> in terms of which types of objects they can contain.