Skip to content
Sharp

Modern Java · interview question

Which method can be overridden in a Java enum to provide custom behavior for each constant?

Multiple choiceMediumchapter-7-curatedpremiummodern-javaenums
Choose one answer
Answer and explanation

Correct answer

B. ToString()

Why

The toString() method can be overridden to provide custom behavior for each enum constant, allowing you to return a specific string representation.

Test yourself on Modern Java

A free test with instant, explained results. No account needed.

Start free test
All Modern Java questions →