Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume that we have defined an enum type Planet and an instance memberMethod() , both in class SolarSystem : class SolarSystem { public enum Planet
Assume that we have defined an enum type Planet and an instance memberMethod(), both in class SolarSystem:
class SolarSystem { public enum Planet { MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE } void memberMethod() { ... } }
Also assume, as usual, that, a totally separate and unrelated class, Foothill, contains the client main().
Which statements have enum-related compiler errors? Assume that these are isolated statements in otherwise sensible, error-free programs and that there are no variables with the names MERCURY,... NEPTUNE anywhere in our program other than the ones seen above.
(There may be more than one correct choice.)
A. public void memberMethod() { Planet myHome = Planet.NEPTUNE; } |
B. public static void main(String[] args) { Planet myHome; myHome = Planet.VENUS; } |
C. public static void main(String[] args) { SolarSystem.Planet myHome; myHome = SolarSystem.Planet.VENUS; } |
D. public static void main(String[] args) { SolarSystem sol = new SolarSystem(); sol.memberMethod(); } |
E. public void memberMethod() { Planet myHome = EARTH; } |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started