单项选择题
Given:
4. class Electricity {int getCharge() {return 24; } }
5. public class Voltage extends Electricity {
6. enum volts {twelve, twentyfour, oneten};
7. public static void main(String[] args) {
8. volts v = velts.twentyfour;
9. switch (v) {
10. case twelve:
11. System.out.print("12 ");
12. default:
13. System.out.print (getCharge() + " ");
14. case oneten:
15. System.out.print("110 ");
16. } } }
What is the result (Choose all that apply.)
A.24
B.24 110
C.24 110 12
D.Compilation fails due to a misuse of enums.
E.Compilation fails due to a non-enum issue.
热门试题
单项选择题Given:2. interface Gadget {3. int patent = 12345;4. Gadget doStuff();5. }6. public class TimeMachine implements Gadget {7. int patent = 34567;8. public static void main(String[] args) {9. new TimeMachine().doStuff();10. }11. TimeMachine doStuff() {12. System.out.println( ++patent);13. return new TimeMachine();14. } }If javac is invoked twice:javac -source 1.4 TimeMachine.Javajavac TimeMachine. javaAnd, if java TimeMachine is invoked whenever TimeMachine compiles, what is the result
A.First, compilation fails, then 12346
B.First, compilation fails, then 34568
C.First, 12346, then compilation fails.
D.First, 34568, then compilation fails.
E.First, 12346, then 34568
F.Compilation fails on both javac invocations.