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.


Can enums be used to create a chain of responsibility?

  1. Yes

  2. No

  3. Only with interfaces

  4. Not applicable

The correct answer is: Yes

Yes, enums can be used to create a chain of responsibility by defining enum constants that represent different handlers, creating a method to assign a handler to each enum constant, and implementing a recursive method to retrieve and execute the correct handler based on the given input. Option B is incorrect because enums can indeed be used to create a chain of responsibility. Option C is incorrect because while interfaces can also be used to create a chain of responsibility, they are not the only option. Option D is incorrect because creating a chain of responsibility is a feasible and applicable use case for enums.