โ Back to Miscellaneous
Question 166
Enum with Field and Constructor
Enum with Field and Constructor
Use an enum with a constructor, field, and getter method to store and retrieve a numeric priority level. Expected Output: Priority level: 3 The starter code provides the full enum: Priority has values LOW(1), MEDIUM(2), HIGH(3), each storing an int level. The constructor sets the field; getLevel() retrieves it. Set p = Priority.HIGH and print p.getLevel().
Expected Output:
Priority level: 3
Topics:
Miscellaneous
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.