Disable ads (and more) with a membership for a one time $4.99 payment
Can enums be used to create a chain of responsibility?
Yes
No
Only with interfaces
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.