Saturday, October 12, 2013

SCJP/OCJP IZO-851 Java Dumps - Five

Q1. Given:
11. int i = 1,j = -1;
12. switch (i) {
13. case 0, 1:j = 1;
14. case 2: j = 2;
15. default; j = 0;
16. }
17. System.out.printIn(“j=”+j);
What is the result?
A. j = -1
B. j = 0
C. j = 1
D. j = 2
E. Compilation fails.
Answer: E
Q2. Given:
1. public class X {
2. public static void main(String [] args) {
3. try {
4. badMethod();
5. System.out.print(“A”);
6. }
7. catch (Exception ex) {
8. System.out.print(“B”);
9. }
10. finally {
11. System.out.print(“C”);
12. }
13. System.out.print(“D”);
14. }
15. public static void badMethod() {}
17. }
What is the result?
A. AC
B. BD
C. ACD
D. ABCD
E. Compilation fails.
Answer: C
Q3. Which two are valid declarations within an interface definition? (Choose two)
A. void methoda();
B. public double methoda();
C. public final double methoda();
D. static void methoda(double d1);
E. protected void methoda(double d1);
Answer: A, B
Q4. Which two allow the class Thing to be instantiated using new Thing()? (Choose two)
A. public class Thing {
}
B. public class Thing {
public Thing() {}
}
C. public class Thing {
public Thing(void) {}
}
D. public class Thing {
public Thing(String s) {}
}
E. public class Thing {
public void Thing() {}
public Thing(String s) {}
}
Answer: A, B
Q5. Given:
11. Float f = new Float(“12”);
12. switch (f) {
13. case 12: System.out.printIn(“Twelve”);
14. case 0: System.out.printIn(“Zero”);
15. default: System.out.printIn(“Default”);
16. }
What is the result?
A. Zero
B. Twelve
C. Default
D. Twelve
     Zero
     Default
E. Compilation fails.
Answer: E
Q6. Given:
1. public class X {
2. public static void main(String [] args) {
3. try {
4. badMethod();
5. System.out.print(“A”);
6. }
7. catch (Exception ex) {
8. System.out.print(“B”);
9. }
10. finally {
11. System.out.print(“C”);
12. }
13. System.out.print(“D”);
14. }
15. public static void badMethod() {
16. throw new RuntimeException();
17. }
18. }
What is the result?
A. AB
B. BC
C. ABC
D. BCD
E. Compilation fails.
Answer: D
Q7. Given:
1. class TestA {
2. TestB b;
3. TestA() {
4. b = new TestB(this);
5. }
6. }
7. class TestB {
8. TestA a;
9. TestB(TestA a) {
10. this.a = a;
11. }
12. }
13. class TestAll {
14. public static void main (String args[]) {
15. new TestAll().makeThings();
16. // ...code continues on
17. }
18. void makeThings() {
19. TestA test = new TestA();
20. }
21. }
Which two statements are true after line 15, before main completes? (Choose two)
A. Line 15 causes a stack overflow.
B. An exception is thrown at runtime.
C. The object referenced by a is eligible for garbage collection.
D. The object referenced by b is eligible for garbage collection.
E. The object referenced by a is not eligible for garbage collection.
F. The object referenced by b is not eligible for garbage collection.
Answer: C, F
Q8. Given:
11. for (int i =0; i <3; i++) {
12. switch(i) {
13. case 0: break;
14. case 1: System.out.print(“one “);
15. case 2: System.out.print(“two “);
16. case 3: System.out.print(“three “);
17. }
18. }
19. System.out.println(“done”);
What is the result?
A. done
B. one two done
C. one two three done
D. one two three two three done
E. Compilation fails.
Answer: D
Q9. Which three statements are true? (Choose three)
A. The default constructor initializes method variables.
B. The default constructor has the same access as its class.
C. The default constructor invoked the no-arg constructor of the superclass.
D. If a class lacks a no-arg constructor, the compiler always creates a default constructor.
E. The compiler creates a default constructor only when there are no other constructors
for the class.
Answer: B, C, E

No comments :

Post a Comment

iVTech Pageviews