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 change did Java SE5 introduce regarding the use of interfaces for constants?

  1. Allowed methods to be defined

  2. Disallowed this practice

  3. Replaced with enums

  4. Introduced default methods

The correct answer is: Replaced with enums

The correct answer is C replaced with enums. This is because prior to Java SE5, constants were defined in interfaces and had to be implemented by classes. This was not an optimal structure as classes could not inherit from multiple classes but could implement multiple interfaces. Therefore, Java SE5 introduced enums which are specially designed classes that can be used to define constants, removing the limitation of classes only being able to inherit from one class. Options A and D are incorrect because while Java SE5 did introduce the concept of default methods for interfaces, this was not in relation to constants. Option B is incorrect because Java SE5 did not disallow the practice of defining constants in interfaces, it simply introduced an alternative and more efficient option.