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 exam details:

Q121. Given:

21. abstract class C1 {

22. public C1() { System.out.print(1); }

23. }

24. class C2 extends C1 {

25. public C2() { System.out.print(2); }

26. }

27. class C3 extends C2 {

28. public C3() { System.out.println(3); }

29. }

30. public class Ctest {

31. public static void main(String[] a) { new C3(); }

32. }

What is the result?

A. 3

B. 23

C. 32

D. 123

E. 321

F. Compilation fails.

G. An exception is thrown at runtime.

Answer: D


Q122. Given:

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

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

13. if (i > 6) break;

14. }

15. System.out.println(i);

16. }

What is the result?

A. 6

B. 7

C. 10

D. 11

E. Compilation fails.

F. An exception is thrown at runtime.

Answer: E


Q123. 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


Q124. Given:

21. class Money {

22. private String country = "Canada";

23. public String getC() { return country; }

24. }

25. class Yen extends Money {

26. public String getC() { return super.country; }

27. }

28. public class Euro extends Money {

29. public String getC(int x) { return super.getC(); }

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

31. System.out.print(new Yen().getC() + " " + new Euro().getC());

32. }

33. }

What is the result?

A. Canada

B. null Canada

C. Canada null

D. Canada Canada

E. Compilation fails due to an error on line 26.

F. Compilation fails due to an error on line 29.

Answer: E


Q125. Given:

5. class Atom {

6. Atom() { System.out.print("atom "); }

7. }

8. class Rock extends Atom {

9. Rock(String type) { System.out.print(type); }

10. }

11. public class Mountain extends Rock {

12. Mountain() {

13. super("granite ");

14. new Rock("granite ");

15. }

16. public static void main(String[] a) { new Mountain(); }

17. }

What is the result?

A. Compilation fails.

B. atom granite

C. granite granite

D. atom granite granite

E. An exception is thrown at runtime.

F. atom granite atom granite

Answer: F


1Z0-851  actual test

Down to date 1z0-851 latest dumps free download:

Q126. Given:

10. interface Foo { int bar(); }

11. public class Sprite {

12. public int fubar( Foo foo ) { return foo.bar(); }

13. public void testFoo() {

14. fubar(

15. // insert code here

16. );

17. }

18. }

Which code, inserted at line 15, allows the class Sprite to compile?

A. Foo { public int bar() { return 1; }

B. new Foo { public int bar() { return 1; }

C. new Foo() { public int bar() { return 1; }

D. new class Foo { public int bar() { return 1; }

Answer: C


Q127. DRAG DROP

Click the Task button.


Answer:


Q128. Given:

11. static class A {

12. void process() throws Exception { throw new Exception(); }

13. }

14. static class B extends A {

15. void process() { System.out.println("B"); }

16. }

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

18. new B().process();

19. }

What is the result?

A. B

B. The code runs with no output.

C. Compilation fails because of an error in line 12.

D. Compilation fails because of an error in line 15.

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

Answer: A


Q129. DRAG DROP

Click the Task button.


Answer:


Q130. Given:

11. // insert code here

12. private N min, max;

13. public N getMin() { return min; }

14. public N getMax() { return max; }

15. public void add(N added) {

16. if (min == null || added.doubleValue() < min.doubleValue())

17. min = added;

18. if (max == null || added.doubleValue() > max.doubleValue())

19. max = added;

20. }

21. }

Which two, inserted at line 11, will allow the code to compile? (Choose two.)

A. public class MinMax<?> {

B. public class MinMax<? extends Number> {

C. public class MinMax<N extends Object> {

D. public class MinMax<N extends Number> {

E. public class MinMax<? extends Object> {

F. public class MinMax<N extends Integer> {

Answer: DF