Friday, October 11, 2013

SCJP/OCJP IZO-851 Java Dumps - Two

Q1. You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
A. public
B. private
C. protected
D. transient
E. default access
Answer: E
Q2. Given:
11. int x = 3;
12. int y = 1;
13. if (x = y) {
14. System.out.println(“x = “ + x);
15. }
What is the result?
A. x = 1
B. x = 3
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
Answer: C
Q3. Given:
1. public class Test {
2. public static void aMethod() throws Exception {
3. try {
4. throw new Exception();
5. } finally {
6. System.out.println(“finally”);
7. }
8. }
9. public static void main(String args[]) {
10. try {
11. aMethod();
12. } catch (Exception e) {
13. System.out.println(“exception”);
14. }
15. System.out.println(“finished”);
16. }
17. }
What is the result?
A. finally
B. exception
finished
C. finally
exception
finished
D. Compilation fails.
Answer: C
Q4. Given:
1. public interface Foo {
2. int k = 4;
3. }
Which three are equivalent to line 2? (Choose three)
A. final int k = 4;
B. public int k = 4;
C. static int k = 4;
D. abstract int k = 4;
E. volatile int k = 4;
F. protected int k = 4;
Answer: A, B, C
Q5. Given:
1. package test1;
2. public class Test1 {
3. static int x = 42;
4. }
1. package test2;
2. public class Test2 extends test1.Test1 {
3. public static void main(String[] args) {
4. System.out.println(“x = “ + x);
5. }
6. }
What is the result?
A. x = 0
B. x = 42
C. Compilation fails because of an error in line 2 of class Test2.
D. Compilation fails because of an error in line 3 of class Test1.
E. Compilation fails because of an error in line 4 of class Test2.
Answer: D
Q6. Given:
1. class A {
2. protected int method1(int a, int b) { return 0; }
3. }
Which two are valid in a class that extends class A? (Choose two)
A. public int method1(int a, int b) { return 0; }
B. private int method1(int a, int b) { return 0; }
C. private int method1(int a, long b) { return 0; }
D. public short method1(int a, int b) { return 0: }
E. static protected int method1(int a, int b) { return 0; }
Answer: A, C
Q7. Given:
1. public class Delta {
2. static boolean foo(char c) {
3. System.out.print(c);
4. return true;
5. }
6. public static void main( String[] argv ) {
7. int i =0;
8. for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){
9. i++ ;
10. foo(‘D’);
12. }
13. }
14. }
What is the result?
A. ABDCBDCB
B. ABCDABCD
C. Compilation fails.
D. An exception is thrown at runtime.
Answer: A
Q8. Given:
1. public class Test{
2. public static void main( String[] argv ){
3. // insert statement here
4. }
5. }
Which statement, inserted at line 3, produces the following output?
Exception in thread “main” java.lang.AssertionError: true
at Test.main(Test.java:3)
A. assert true;
B. assert false;
C. assert false : true;
D. assert false == true;
E. assert false: false;
Answer: C
Q9. Given:
1. public class ArrayTest {
2. public static void main(String[] args) {
3. float fl[], f2[];
4. fl = new float[10];
5. f2 = f1;
6. System.out.println(“f2[0]= “ + f2[0]);
7. }
8. }
What is the result?
A. It prints f2[0] = 0.0.
B. It prints f2[0] = NaN.
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an expectation at runtime.
Answer: A

No comments :

Post a Comment

iVTech Pageviews