How do you define custom fields for enum constants?

  1. By using static variables only
  2. By passing parameters to the enum constructor
  3. By overriding the enum class
  4. You can't define fields in enums
Correct answer By passing parameters to the enum constructor

Explanation

You can pass parameters to an enum constructor and store them in fields.

Update: Admin added a tag on this question

Topics

By Admin · · 35 views