1Z0-851 | What Highest Quality 1Z0-851 dumps Is?


Q41. Given:

1. public class TestOne implements Runnable {

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

3. Thread t = new Thread(new TestOne());

4. t.start();

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

6. t.join();

7. System.out.print("Complete");

8. }

9. public void run() {

10. for (int i = 0; i < 4; i++) {

11. System.out.print(i);

12. }

13. }

14. }

What can be a result?

A. Compilation fails.

B. An exception is thrown at runtime.

C. The code executes and prints "StartedComplete".

D. The code executes and prints "StartedComplete0123".

E. The code executes and prints "Started0123Complete".

Answer: E

Q42. Given:

11. public class Test {

12. public enum Dogs {collie, harrier, shepherd};

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

14. Dogs myDog = Dogs.shepherd;

15. switch (myDog) {

16. case collie:

17. System.out.print("collie ");

18. case default:

19. System.out.print("retriever ");

20. case harrier:

21. System.out.print("harrier ");

22. }

23. }

24. }

What is the result?

A. harrier

B. shepherd

C. retriever

D. Compilation fails.

E. retriever harrier

F. An exception is thrown at runtime.

Answer: D

Q43. Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:

1. import java.io.*;

2. public class Maker {

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

4. File dir = new File("dir");

5. File f = new File(dir, "f");

6. }

7. }

Which statement is true?

A. Compilation fails.

B. Nothing is added to the file system.

C. Only a new file is created on the file system.

D. Only a new directory is created on the file system.

E. Both a new file and a new directory are created on the file system.

Answer: B

Q44. Click the Exhibit button. What is the output of the program shown in the exhibit?

A. 300-100-100-100-100

B. 300-300-100-100-100

C. 300-300-300-100-100

D. 300-300-300-300-100

Answer: B

Q45. Given:

11. static void test() throws RuntimeException {

12. try {

13. System.out.print("test ");

14. throw new RuntimeException();

15. }

16. catch (Exception ex) { System.out.print("exception "); }

17. }

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

19. try { test(); }

20. catch (RuntimeException ex) { System.out.print("runtime "); }

21. System.out.print("end ");

22. }

What is the result?

A. test end

B. Compilation fails.

C. test runtime end

D. test exception end

E. A Throwable is thrown by main at runtime.

Answer: D

Q46. A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting?

A. Looser coupling

B. Tighter coupling

C. Lower cohesion

D. Higher cohesion

E. Weaker encapsulation

F. Stronger encapsulation

Answer: A

Q47. Click the Exhibit button. What is the result?

A. go in Goban

go in Sente

B. go in Sente

go in Goban

C. go in Sente

go in Goban

D. go in Goban

go in Sente

E. Compilation fails because of an error in line 17.

Answer: C

Q48. Given:

11. class Mammal { }

12.

13. class Raccoon extends Mammal {

14. Mammal m = new Mammal();

15. }

16.

17. class BabyRaccoon extends Mammal { } Which four statements are true? (Choose four.)

A. Raccoon is-a Mammal.

B. Raccoon has-a Mammal.

C. BabyRaccoon is-a Mammal.

D. BabyRaccoon is-a Raccoon.

E. BabyRaccoon has-a Mammal.

F. BabyRaccoon is-a BabyRaccoon.

Answer: ABCF

Q49. Given:

10. abstract public class Employee {

11. protected abstract double getSalesAmount();

12. public double getCommision() {

13. return getSalesAmount() * 0.15;

14. }

15. }

16. class Sales extends Employee {

17. // insert method here

18. }

Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)

A. double getSalesAmount() { return 1230.45; }

B. public double getSalesAmount() { return 1230.45; }

C. private double getSalesAmount() { return 1230.45; }

D. protected double getSalesAmount() { return 1230.45; }

Answer: BD

Q50. Given:

12. import java.util.*;

13. public class Explorer2 {

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

15. TreeSet<Integer> s = new TreeSet<Integer>();

16. TreeSet<Integer> subs = new TreeSet<Integer>();

17. for(int i = 606; i < 613; i++)

18. if(i%2 == 0) s.add(i);

19. subs = (TreeSet)s.subSet(608, true, 611, true);

20. s.add(629);

21. System.out.println(s + " " + subs);

22. }

23. }

What is the result?

A. Compilation fails.

B. An exception is thrown at runtime.

C. [608, 610, 612, 629] [608, 610]

D. [608, 610, 612, 629] [608, 610, 629]

E. [606, 608, 610, 612, 629] [608, 610]

F. [606, 608, 610, 612, 629] [608, 610, 629]

Answer: E