What is the result?
A. woof burble
B. Multiple compilation errors
C. Compilation fails due to an error on line 2
D. Compilation fails due to an error on line 3
E. Compilation fails due to an error on line 4
F. Compilation fails due to an error on line 9
Answer:
A is correct; enums can have constructors and variables.
B, C, D, E, and F are incorrect; these lines all use correct syntax.
==
A. woof burble
B. Multiple compilation errors
C. Compilation fails due to an error on line 2
D. Compilation fails due to an error on line 3
E. Compilation fails due to an error on line 4
F. Compilation fails due to an error on line 9
Answer:
A is correct; enums can have constructors and variables.
B, C, D, E, and F are incorrect; these lines all use correct syntax.
==
enum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String [] args) { System.out.println(a.DOG.sound + " " + a.FISH.sound); } }
No comments:
Post a Comment