Multiple choice technology programming languages

Given: 1. package sun.scjp; 2. public enum Color { RED, GREEN, BLUE } 1. package sun.beta; 2. // insert code here 3. public class Beta { 4. Color g = GREEN; 5. public static void main( String[] argv) 6. { System.out.println( GREEN); } 7. } The class Beta and the enum Color are in different packages. Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?

  1. import sun.scjp.; import static sun.scjp.Color.;

  2. import sun.scjp.Color; import static sun.scjp.Color.*;

  3. import sun.scjp.Color.*;

  4. import sun.scjp.Color; import static sun.scjp.Color.GREEN;

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

To use an enum from a different package, you need both: (1) a regular import for the enum class itself, and (2) a static import for the enum constants (either .* for all constants or the specific constant name). Option B imports the class and all constants statically. Option D imports the class and just the GREEN constant specifically.