Given the following program:.
enum Main {//from ww w . j a v a 2 s . c o m GOOD(Level.C), BETTER(Level.B), BEST(Level.A); enum Level {A, B, C} private Level level; Main(Level level) { this.level = level; } public Level getLevel() { return level; } } public class MainClient { public static void main (String[] args) { System.out.println(/* (1) INSERT CODE HERE */); } }
Which code, when inserted at (1), will make the program print true?.
Select the four correct answers.
(a) Main.GOOD.getLevel() != Main.Level.C (b) Main.GOOD.getLevel().compareTo(Main.Level.C) != 0 (c) Main.GOOD.getLevel().compareTo(Main.Level.A) > 0 (d) Main.GOOD.compareTo(Main.BEST) > 0 (e) Main.GOOD.getLevel() instanceof Main.Level (f) Main.GOOD instanceof Main (g) Main.GOOD.getLevel().toString().equals(Main.Level.C.toString())
(c), (e), (f), and (g)
Note how the nested enum type constants are accessed.
Enum constants of an enum type can be compared, and an enum constant is an instance of its enum type.