Want to know Testking 1Z0-851 Exam practice test features? Want to lear more about Oracle Java Standard Edition 6 Programmer Certified Professional Exam certification experience? Study High value Oracle 1Z0-851 answers to Far out 1Z0-851 questions at Testking. Gat a success with an absolute guarantee to pass Oracle 1Z0-851 (Java Standard Edition 6 Programmer Certified Professional Exam) test on your first attempt.

2021 Sep pdf 1z0-851:

Q31. Given:

10: public class Hello {

11: String title;

12: int value;

13: public Hello() {

14: title += " World";

15: }

16: public Hello(int value) {

17: this.value = value;

18: title = "Hello";

19: Hello();

20: }

21: } and:

30: Hello c = new Hello(5);

31: System.out.println(c.title);

What is the result?

A. Hello

B. Hello World

C. Compilation fails.

D. Hello World 5

E. The code runs with no output.

F. An exception is thrown at runtime.

Answer: C


Q32. Given:

11. static void test() throws Error {

12. if (true) throw new AssertionError();

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

14. }

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

16. try { test(); }

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

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

19. }

What is the result?

A. end

B. Compilation fails.

C. exception end

D. exception test end

E. A Throwable is thrown by main.

F. An Exception is thrown by main.

Answer: E


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


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


A. 4321

B. 0000

C. An exception is thrown at runtime.

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

Answer: D


Q35. Given:

1. package test;

2.

3. class Target {

4. public String name = "hello";

5. }

What can directly access and change the value of the variable name?

A. any class

B. only the Target class

C. any class in the test package

D. any class that extends Target

Answer: C


1Z0-851  free practice questions

Renovate ocjp 1z0-851 exam:

Q36. Given:

31. class Foo {

32. public int a = 3;

33. public void addFive() { a += 5; System.out.print("f "); }

34. }

35. class Bar extends Foo {

36. public int a = 8;

37. public void addFive() { this.a += 5; System.out.print("b " ); }

38. } Invoked with: Foo f = new Bar(); f.addFive(); System.out.println(f.a);

What is the result?

A. b 3

B. b 8

C. b 13

D. f 3

E. f 8

F. f 13

G. Compilation fails.

H. An exception is thrown at runtime.

Answer: A


Q37. Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a

Sprocket Which two code fragments represent these relationships? (Choose two.)

A. class Widget { Sprocket s; }

class Gadget extends Widget { Spring s; }

B. class Widget { }

class Gadget extends Widget { Spring s1; Sprocket s2; }

C. class Widget { Sprocket s1; Spring s2; }

class Gadget extends Widget { }

D. class Gadget { Spring s; }

class Widget extends Gadget{ Sprocket s; }

E. class Gadget { }

class Widget extends Gadget{ Sprocket s1; Spring s2; }

F. class Gadget { Spring s1; Sprocket s2; }

class Widget extends Gadget{ }

Answer: AC


Q38. Given:

11. public static void parse(String str) {

12. try {

13. float f = Float.parseFloat(str);

14. } catch (NumberFormatException nfe) {

15. f = 0;

16. } finally {

17. System.out.println(f);

18. }

19. }

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

21. parse("invalid");

22. }

What is the result?

A. 0.0

B. Compilation fails.

C. A ParseException is thrown by the parse method at runtime.

D. A NumberFormatException is thrown by the parse method at runtime.

Answer: B


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


Q40. Given:

1. public class TestOne {

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

3. Thread.sleep(3000);

4. System.out.println("sleep");

5. }

6. }

What is the result?

A. Compilation fails.

B. An exception is thrown at runtime.

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

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

Answer: C