Given:
1. enum Pet { // www .ja v a 2 s .co m 2. DOG("woof"), CAT("meow"), FISH("burble"); 3. String sound; 4. Pet(String s) { sound = s; } 5. } 6. class TestEnum { 7. static Pet a; 8. public static void main(String[] args) { 9. System.out.println(a.DOG.sound + " " + a.FISH.sound); 10. } 11. }
What is the result?
A is correct; enums can have constructors and variables.
B, C, D, E, and F are incorrect; these lines all use correct syntax.