Java Reference
In-Depth Information
A.
1234
B.
3123
C.
3142
D.
3124
E.
The code does not compile.
21.
Given the following enum declaration:
1. public enum Fruit {
2. APPLE(“red”),
3. BANANA(“yellow”),
4. ORANGE(“orange”),
5. PLUM(“purple”);
6.
7. private Fruit(String color) {
8. this.color = color;
9. }
10.
11. public String color;
12. }
what is the result of the following program?
15. public class FruitStore {
16. public static void main(String [] args) {
17. Fruit one = Fruit.PLUM;
18. System.out.println(“a “ + one.name() + “ is “ + one.color);
19. }
20. }
A.
a PLUM is purple
B.
a Fruit.PLUM is purple
C.
The Fruit enum does not compile.
D.
Compiler error on line 17
E.
Compiler error on line 18
22.
Given the following class definition:
1. class Outer {
2. private int x = 24;
3.
4. public int getX() {
5. String message = “x is “;
6. class Inner {
7. private int x = Outer.this.x;
8. public void printX() {
Search WWH ::
Custom Search