Skip to content
Sharp

Modern Java · interview question

Which of the following best utilizes a Java enum for representing order statuses in an e-commerce application?

Multiple choiceEasychapter-7-curatedpremiummodern-javamodern-java-design-choices
java
enum OrderStatus { PENDING, SHIPPED, DELIVERED }
Choose one answer
Answer and explanation

Correct answer

C. Using an enum with entries like PENDING, SHIPPED, DELIVERED

Why

Enums are ideal for representing a fixed set of constants, like order statuses, because they enhance type safety and make the code more readable and maintainable.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →