Saturday, October 12, 2013

SCJP/OCJP IZO-851 Java Dumps - Six

Q1. Which three statements are true? (Choose three)
A. Assertion checking is typically enabled when a program is deployed.
B. It is never appropriate to write code to handle failure of an assert statement.
C. Assertion checking is typically enabled during program development and testing.
D. Assertion checking can be selectively enabled or disable an a per-package basis, but
not on a per-class basis.
E. Assertion checking can be selectively enabled or disabled on both a per-package basis
and a per-class basis.
Answer: B, C, E
Q2. Which statement is true?
A. A try statement must have at least one corresponding catch block.
B. Multiple catch statements can catch the same class of exception more than once.
C. An Error that might be thrown in a method must be declared as thrown by that
method, or be handled within that method.
D. Except in case of VM shutdown, if a try block starts to execute, a corresponding
finally block will always start to execute.
E. Except in case of VM shutdown, if a try block starts to execute, a corresponding
finally block must always run to completion.
Answer: E
Q3. Given:
1. class A {
2. final public int method1(int a, int b) {return 0; }
3. }
4. class B extends A {
5. public int method1(int a, int b) { return 1; }
6. }
7. public class Test {
8. public static void main(Strings args[]) {
9. B b;
10. System.out.println(“x = “ + b.method1(0, 1));
11. }
12. }
What is the result?
A. x = 0
B. x = 1
C. Compilation fails.
D. En exception is thrown at runtime.
Answer: C
Q4. Given:
10. public Object m() {
11. Object o = new Float(3.14F);
12. Object [] oa = new Object[1];
13. oa[0] = o;
14. o = null;
15. oa[0] = null;
16. return 0;
17. }
When is the Float object, created in line 11, eligible for garbage collection?
A. Just after line 13.
B. Just after line 14.
C. Just after line 15.
D. Just after line 16 (that is, as the method returns).
Answer: B
Q5. Given:
11. public void test(int x) {
12. int odd = x%2;
13. if (odd) {
14. System.out.println(“odd);
15. } else {
16. System.out.println(“even”);
17. }
18. }
Which statement is true?
A. Compilation fails.
B. “odd” will always be output.
C. “even” will always be output.
D. “odd” will be output for odd values of x, and “even” for even values.
E. “even” will be output for add values of x, and “odd” for even values.
Answer: A
Q6. Which two create an instance of an array? (Choose two)
A. int[] ia = new int[15];
B. float fa = new float[20];
C. char[] ca = “Some String”;
D. Object oa = new float[20];
E. int ia[][] = { 4, 5, 6, }, { 1, 2, 3 };
Answer: A, D
Q7. Given:
1. class Super {
2. public int getLenght() { return 4; }
3. }
4.
5. public class Sub extends Super {
6. public long getLenght() { return 5; }
7.
8. public static void main(String[] args) {
9. Super sooper = new Super();
10. Sub sub = new Sub();
11. System.out.println(
12. sooper.getLenght() + “,” + sub.getLenght() );
13. }
14. }
What is the output?
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. Compilation fails.
Answer: E
Q8. Given:
1. public class Test {
2. public static void main(String[] args) {
3. int x = 0;
4. assert (x > 0): “assertion failed”;
5. System.out.printIn(“finished”);
6. }
7. }
What is the result?
A. finished
B. Compilation fails.
C. An AssertionError is thrown.
D. An AssertionError is thrown and finished is output.
Answer: A
Q9. You want to limit access to a method of a public class to members of the same class. Which access accomplishes this objective?
A. public
B. private
C. protected
D. transient
E. default access
Answer: B

No comments :

Post a Comment

iVTech Pageviews