Assessment Multitude: 1Z0-851?
Affiliated Certifications: Oracle
On the market languages: English language, Western, Asian, How to speak spanish, Russian, Korean, This particular language, Colonial
Assessment Identify : Java Standard Edition 6 Programmer Certified Professional Exam
Questions and Answers : [productnum] Q&As
Upgrade Point in time: [productupdatetime]
Expense:? [productprice]

2021 Aug ocjp 1z0-851:

Q61. Given:

11. class ClassA {}

12. class ClassB extends ClassA {}

13. class ClassC extends ClassA {} and:

21. ClassA p0 = new ClassA();

22. ClassB p1 = new ClassB();

23. ClassC p2 = new ClassC();

24. ClassA p3 = new ClassB();

25. ClassA p4 = new ClassC();

Which three are valid? (Choose three.)

A. p0 = p1;

B. p1 = p2;

C. p2 = p4;

D. p2 = (ClassC)p1;

E. p1 = (ClassB)p3;

F. p2 = (ClassC)p4;

Answer: AEF


Q62. Given:

1. public class Boxer1{

2. Integer i;

3. int x;

4. public Boxer1(int y) {

5. x = i+y;

6. System.out.println(x);

7. }

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

9. new Boxer1(new Integer(4));

10. }

11. }

What is the result?

A. The value "4" is printed at the command line.

B. Compilation fails because of an error in line 5.

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

D. A NullPointerException occurs at runtime.

E. A NumberFormatException occurs at runtime.

F. An IllegalStateException occurs at runtime.

Answer: D


Q63. A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)

A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.

B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..

C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar/Paper.class.

D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar.

E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/

Paper Book.java.

F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar

Book.java

G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/

myLib.jar Book.java

Answer: BDG


Q64. Given:

1. public class Plant {

2. private String name;

3. public Plant(String name) { this.name = name; }

4. public String getName() { return name; }

5. }

1. public class Tree extends Plant {

2. public void growFruit() { }

3. public void dropLeaves() { }

4. }

Which statement is true?

A. The code will compile without changes.

B. The code will compile if public Tree() { Plant(); } is added to the Tree class.

C. The code will compile if public Plant() { Tree(); } is added to the Plant class.

D. The code will compile if public Plant() { this("fern"); } is added to the Plant class.

E. The code will compile if public Plant() { Plant("fern"); } is added to the Plant class.

Answer: D


Q65. Given:

1. public class Plant {

2. private String name;

3. public Plant(String name) { this.name = name; }

4. public String getName() { return name; }

5. }

1. public class Tree extends Plant {

2. public void growFruit() { }

3. public void dropLeaves() { }

4. }

Which statement is true?

A. The code will compile without changes.

B. The code will compile if public Tree() { Plant(); } is added to the Tree class.

C. The code will compile if public Plant() { Tree(); } is added to the Plant class.

D. The code will compile if public Plant() { this("fern"); } is added to the Plant class.

E. The code will compile if public Plant() { Plant("fern"); } is added to the Plant class.

Answer: D


2passeasy.com

Down to date 1z0-851 ocjp dumps:

Q66. Given:

1. public class KungFu {

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

3. Integer x = 400;

4. Integer y = x;

5. x++;

6. StringBuilder sb1 = new StringBuilder("123");

7. StringBuilder sb2 = sb1;

8. sb1.append("5");

9. System.out.println((x==y) + " " + (sb1==sb2));

10. }

11. }

What is the result?

A. true true

B. false true

C. true false

D. false false

E. Compilation fails.

F. An exception is thrown at runtime.

Answer: B


Q67. Given:

3. public class Breaker {

4. static String o = "";

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

6. z:

7. o = o + 2;

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

9. if(x==4) break;

10. if(x==6) break z;

11. o = o + x;

12. }

13. System.out.println(o);

14. }

15. }

What is the result?

A. 23

B. 234

C. 235

D. 2345

E. 2357

F. 23457

G. Compilation fails.

Answer: G


Q68. Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)

A. int []x = {1,2,3,4,5};

for(int y = 0; y < 6; y++)

System.out.println(x[y]);

B. static int[] x = {7,6,5,4};

static { x[1] = 8;

x[4] = 3; }

C. for(int y = 10; y < 10; y++)

doStuff(y);

D. void doOne(int x) { doTwo(x); }

void doTwo(int y) { doThree(y); }

void doThree(int z) { doTwo(z); }

E. for(int x = 0; x < 1000000000; x++)

doStuff(x);

F. void counter(int i) { counter(++i); }

Answer: DF


Q69. Given:

3. public class Batman {

4. int squares = 81;

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

6. new Batman().go();

7. }

8. void go() {

9. incr(++squares);

10. System.out.println(squares);

11. }

12. void incr(int squares) { squares += 10; }

13. }

What is the result?

A. 81

B. 82

C. 91

D. 92

E. Compilation fails.

F. An exception is thrown at runtime.

Answer: B


Q70. Given:

10. class Nav{

11. public enum Direction { NORTH, SOUTH, EAST, WEST }

12. }

13. public class Sprite{

14. // insert code here

15. }

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

A. Direction d = NORTH;

B. Nav.Direction d = NORTH;

C. Direction d = Direction.NORTH;

D. Nav.Direction d = Nav.Direction.NORTH;

Answer: D