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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What modification can be used to avoid qualifying enum instances in 'TrafficLight.java'?

  1. Using default import

  2. Using static import

  3. Extending the enum class

  4. Implementing an interface

The correct answer is: Using static import

One possible explanation The other choices will not work to avoid qualifying enum instances in 'TrafficLight.java'. A and C are irrelevant since they involve imports and extending the enum class, respectively. D is also incorrect because implementing an interface is not a valid way to avoid qualifying enum instances. The only choice that makes sense for this task is using static import, which allows for using the enum instances without qualifying them with the enum class name.