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 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.