Rather than declaring an enum public enum Navigation { LEFT, RIGHT, STRAIGHT } I
ID: 3696552 • Letter: R
Question
Rather than declaring an enum public enum Navigation { LEFT, RIGHT, STRAIGHT }
I could also have an int variable navigation and assign it different values - let's say 0 for left, 1 for right and 2 for straight. In both cases I could keep track of my navigation, however, there are 2 major advantages of using an enum.
Check the TWO main reasons why we should use an enum
A. It allows the compiler to catch errors
B. It requires less typing
C. It provides the user with more choices
D. It makes the code clear and easy to read
Explanation / Answer
option A.it allowsthe compiler to catch errors
option D.It makes the code clear and easy to read
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.