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 alternative do enums have since they cannot be inherited from?

  1. Extending classes

  2. Implementing interfaces

  3. Static importing

  4. None of the above

The correct answer is: Implementing interfaces

Enums in Java cannot be inherited from, so options A and C, which describe a process of inheriting attributes from other classes, are incorrect. Option D is also incorrect because there is another alternative for enums besides inheritance. Rather, enums have the alternative of implementing interfaces, which allows them to define their own methods and attributes while still preventing them from being inherited. This is why option B is the correct answer.