Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?

Given:
11. public class Ball{
12. public enum Color { RED, GREEN, BLUE };
13. public void foo(){
14. // insert code here

15. { System.out.println(c); }
16. }
17. }
Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?

Given:
11. public class Ball{
12. public enum Color { RED, GREEN, BLUE };
13. public void foo(){
14. // insert code here

15. { System.out.println(c); }
16. }
17. }
Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?

A.
for( Color c : Color.values() )

B.
for( Color c = Color[0]; c <= Color[2]; c++ )

C.
for( Color c = Color.RED; c <= Color.BLUE; c++ )

D.
for( Color c = RED; c <= BLUE; c++ )

E.
for( Color c ; c.hasNext() ; c.next() )



Leave a Reply 0

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