repeated q & a in scjp exam
Friday, January 29, 2010
5:31 AM
,
0 Comments
Labels: Frequently asked quesions in scjp exam , SCJP FAQ , SCJP MATERIAL , SCJP Mock Exam , scjp objects , scjp q and answers
Labels: Frequently asked quesions in scjp exam , SCJP FAQ , SCJP MATERIAL , SCJP Mock Exam , scjp objects , scjp q and answers
Goto main page
28. Given:
1. enum Animals {
2. DOG("woof"), CAT("meow"), FISH("burble");
3. String sound;
4. Animals(String s) { sound = s; }
5. }
6. class TestEnum {
7. static Animals 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. 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.
29. Given:
1. enum A { A }
2. class E2 {
3. enum B { B }
4. void C() {
5. enum D { D }
6. }
7. }
Which statements are true? (Choose all that apply.)
A. The code compiles.
B. If only line 1 is removed the code compiles.
C. If only line 3 is removed the code compiles.
D. If only line 5 is removed the code compiles.
E. If lines 1 and 3 are removed the code compiles.
F. If lines 1, 3 and 5 are removed the code compiles.
Answer
->D and F are correct. Line 5 is the only line that will not compile, because enums cannot belocal to a method.
->A, B, C and E are incorrect based on the above.
Goto main page



0 Response to "repeated q & a in scjp exam"
Post a Comment