JAVA DUMPS 11(SCJP)

QUESTION NO: 54

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


 

QUESTION NO: 55

Given:

11. switch(x) {

12. default:

13. System.out.printIn("Hello");

14. }

Which two are acceptable types for x? (Choose two)

A. byte

B. long

C. char

D. float

E. Short

F. Long

Answer: A, C


 

QUESTION NO: 56

Given:

1. public class X {

2. public static void main(String [] args) {

3. try {

4. badMethod();

5. System.out.print("A");

6. }

7. catch (RuntimeException ex) {

8. System.out.print("B");

9. }

10. catch (Exception ex1) {

11. System.out.print("C");

12. }

13. finally {

14. System.out.print("D");

15. }

16. System.out.print("E");

17. }

18. public static void badMethod() {

19. throw new RuntimeException();

20. }

21. }

What is the result?

A. BD

B. BCD

C. BDE

D. BCDE

E. ABCDE

F. Compilation fails.

Answer: C


 

QUESTION NO: 57

Given:

1. public class Test {

2. public static void main(String[] args) {

3. int x = 0;

4. assert (x > 0) ? "assertion failed" : "assertion passed";

5. System.out.println("Finished");

6. }

7. }

What is the result?

A. finished

B. Compilation fails.

C. An AssertionError is thrown and finished is output.

D. An AssertionError is thrown with the message "assertion failed".

E. An AssertionError is thrown with the message "assertion passed".

Answer: B

QUESTION NO: 58

Given:

1. public class ReturnIt {

2. return Type methodA(byte x, double y) {

3. return (long)x / y * 2;

4. }

5. }

What is the narrowest valid returnType for methodA in line2?

A. int

B. byte

C. long

D. short

E. float

F. double

Answer: F


 

QUESTION NO: 59

Given:

1. public class OuterClass {

2. private double d1 = 1.0;

3. // insert code here

4. }

Which two are valid if inserted at line 3? (Choose two)

A. static class InnerOne {

public double methoda() { return d1; }

}

B. static class InnerOne {

static double methoda() { return d1; }

}

C. private class InnerOne {

public double methoda() { return d1; }

}

D. protected class InnerOne {

static double methoda() { return d1; }

}

E. public abstract class InnerOne {

public abstract double methoda();

}

Answer: C, E

2 comments:

Anonymous said...

A very good study material!!!!

Anonymous said...

answer of Question 55 is wrong
A switch's expression must evaluate to a char,byte,int,or,as of java6, an enum.

Post a Comment