Assume that we have defined an enum type Planet and an instance memberMethod(), both in classSolarSystem:
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;
}
|