Java Reference
In-Depth Information
17. Given the following enum definition:
1. public enum Flavors {
2. VANILLA, CHOCOLATE, STRAWBERRY
3. }
what is the output from the following code?
9. Flavors f = Flavors.STRAWBERRY;
10. switch(f) {
11. case 0:
12. System.out.println(“vanilla”);
13. case 1:
14. System.out.println(“chocolate”);
15. case 2:
16. System.out.println(“strawberry”);
17. break;
18. default:
19. System.out.println(“missing flavor”);
20. }
A. vanilla
B. chocolate
C. strawberry
D. missing flavor
E. The code does not compile.
18. Given the following class definition:
1. import java.awt.*;
2. import java.awt.event.*;
3.
4. public class MyWindow {
5. private Frame frame = new Frame();
6.
7. public void registerEvents() {
8. WindowAdapter wa = new WindowAdapter() {
9. public void windowClosing(WindowEvent e) {
10. frame.setVisible(false);
11. frame.dispose();
12. }
13. };
14. frame.addWindowListener(wa);
15. }
16.}
Search WWH ::




Custom Search