Which two, inserted independently at line 13, allow the code to compile?

Given:
1. public enum Color { RED, YELLOW, GREEN }
2. enum Fruit {
3. Banana(Color.RED),
4. Apple(Color.YELLOW),
5. Kiwi(Color.GREEN);
6. private Color color;

7. Fruit(Color color) {
8. this.color = color;
9. }
10. }
11. class Test {
12. public void method() {
13. // insert code here
14. }
15. }
Which two, inserted independently at line 13, allow the code to compile? (Choose two.)

Given:
1. public enum Color { RED, YELLOW, GREEN }
2. enum Fruit {
3. Banana(Color.RED),
4. Apple(Color.YELLOW),
5. Kiwi(Color.GREEN);
6. private Color color;

7. Fruit(Color color) {
8. this.color = color;
9. }
10. }
11. class Test {
12. public void method() {
13. // insert code here
14. }
15. }
Which two, inserted independently at line 13, allow the code to compile? (Choose two.)

A.
Color red = Color.values[0];

B.
Fruit f = Banana;

C.
Fruit[] fruits = Fruit.values();

D.
Fruit f = new Fruit(Color.RED);

E.
Fruit f = Fruit.Banana; switch (f) { }



Leave a Reply 0

Your email address will not be published. Required fields are marked *