Exam Code: 1Z0-851 (Practice Exam Latest Test Questions VCE PDF)
Exam Name: Java Standard Edition 6 Programmer Certified Professional Exam
Certification Provider: Oracle
Free Today! Guaranteed Training- Pass 1Z0-851 Exam.

2021 Sep 1z0-851 latest dumps:

Q151. Given:

1. import java.util.*;

2. public class WrappedString {

3. private String s;

4. public WrappedString(String s) { this.s = s; }

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

6. HashSet<Object> hs = new HashSet<Object>();

7. WrappedString ws1 = new WrappedString("aardvark");

8. WrappedString ws2 = new WrappedString("aardvark");

9. String s1 = new String("aardvark");

10. String s2 = new String("aardvark");

11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);

12. System.out.println(hs.size()); } }

What is the result?

A. 0

B. 1

C. 2

D. 3

E. 4

F. Compilation fails.

G. An exception is thrown at runtime.

Answer: D


Q152. Given

11. public interface Status {

12. /* insert code here */ int MY_VALUE = 10;

13. } Which three are valid on line

12?

(Choose three.)

A. final

B. static

C. native

D. public

E. private

F. abstract

G. protected

Answer: ABD


Q153. Given:

22. public void go() {

23. String o = "";

24. z:

25. for(int x = 0; x < 3; x++) {

26. for(int y = 0; y < 2; y++) {

27. if(x==1) break;

28. if(x==2 && y==1) break z;

29. o = o + x + y;

30. }

31. }

32. System.out.println(o);

33. }

What is the result when the go() method is invoked?

A. 00

B. 0001

C. 000120

D. 00012021

E. Compilation fails.

F. An exception is thrown at runtime.

Answer: C


Q154. Given:

2. public class Hi {

3. void m1() { }

4. protected void() m2 { }

5. }

6. class Lois extends Hi {

7. // insert code here

8. }

Which four code fragments, inserted independently at line 7, will compile? (Choose four.)

A. public void m1() { }

B. protected void m1() { }

C. private void m1() { }

D. void m2() { }

E. public void m2() { }

F. protected void m2() { }

G. private void m2() { }

Answer: ABEF


Q155. A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory / home/bob using the command: java -classpath /test:/home/bob/downloads/*.jar games.Chess Bob's CLASSPATH is set (at login time) to:

/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jar What is a possible location for the Chess.class file?

A. /test/Chess.class

B. /home/bob/Chess.class

C. /test/games/Chess.class

D. /usr/lib/games/Chess.class

E. /home/bob/games/Chess.class

F. inside jarfile /opt/java/lib/Games.jar (with a correct manifest)

G. inside jarfile /home/bob/downloads/Games.jar (with a correct manifest)

Answer: C


1Z0-851  exam price

Regenerate 310-065 vs 1z0-851:

Q156. Given a valid DateFormat object named df, and

16. Date d = new Date(0L);

17. String ds = "December 15, 2004";

18. // insert code here What updates d's value with the date represented by ds?

A. 18. d = df.parse(ds);

B. 18. d = df.getDate(ds);

C. 18. try {

19. d = df.parse(ds);

20. } catch(ParseException e) { };

D. 18. try {

19. d = df.getDate(ds);

20. } catch(ParseException e) { };

Answer: C


Q157. Given:

31. // some code here

32. try {

33. // some code here

34. } catch (SomeException se) {

35. // some code here

36. } finally {

37. // some code here

38. }

Under which three circumstances will the code on line 37 be executed? (Choose three.)

A. The instance gets garbage collected.

B. The code on line 33 throws an exception.

C. The code on line 35 throws an exception.

D. The code on line 31 throws an exception.

E. The code on line 33 executes successfully.

Answer: BCE


Q158. Given:

1. public class Score implements Comparable<Score> {

2. private int wins, losses;

3. public Score(int w, int l) { wins = w; losses = l; }

4. public int getWins() { return wins; }

5. public int getLosses() { return losses; }

6. public String toString() {

7. return "<" + wins + "," + losses + ">";

8. }

9. // insert code here

10. }

Which method will complete this class?

A. public int compareTo(Object o){/*more code here*/}

B. public int compareTo(Score other){/*more code here*/}

C. public int compare(Score s1,Score s2){/*more code here*/}

D. public int compare(Object o1,Object o2){/*more code here*/}

Answer: B


Q159. Given:

1. public class Threads4 {

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

3. new Threads4().go();

4. }

5. public void go() {

6. Runnable r = new Runnable() {

7. public void run() {

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

9. }

10. };

11. Thread t = new Thread(r);

12. t.start();

13. t.start();

14. }

15. }

What is the result?

A. Compilation fails.

B. An exception is thrown at runtime.

C. The code executes normally and prints "foo".

D. The code executes normally, but nothing is printed.

Answer: B


Q160. Given:

1. import java.util.*;

2. public class Example {

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

4. // insert code here

5. set.add(new Integer(2));

6. set.add(new Integer(1));

7. System.out.println(set);

8. }

9. }

Which code, inserted at line 4, guarantees that this program will output [1, 2]?

A. Set set = new TreeSet();

B. Set set = new HashSet();

C. Set set = new SortedSet();

D. List set = new SortedList();

E. Set set = new LinkedHashSet();

Answer: A