1Z0-851 | Simulation Java 1Z0-851 exam dumps


Q81. Given:

1. public class BuildStuff {

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

3. Boolean test = new Boolean(true);

4. Integer x = 343;

5. Integer y = new BuildStuff().go(test, x);

6. System.out.println(y);

7. }

8. int go(Boolean b, int i) {

9. if(b) return (i/7);

10. return (i/49);

11. }

12. }

What is the result?

A. 7

B. 49

C. 343

D. Compilation fails.

E. An exception is thrown at runtime.

Answer: B

Q82. DRAG DROP

Click the Task button.

Answer:

Q83. Given:

10. public class SuperCalc {

11. protected static int multiply(int a, int b) { return a * b;}

12. }

and:

20. public class SubCalc extends SuperCalc{

21. public static int multiply(int a, int b) {

22. int c = super.multiply(a, b);

23. return c;

24. }

25. }

and:

30. SubCalc sc = new SubCalc ();

31. System.out.println(sc.multiply(3,4));

32. System.out.println(SubCalc.multiply(2,2));

What is the result?

A. 12

B. The code runs with no output.

C. An exception is thrown at runtime.

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

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

F. Compilation fails because of an error in line 31.

Answer: E

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

Q85. Given:

1. public class A {

2. public void doit() {

3. }

4. public String doit() {

5. return "a";

6. }

7. public double doit(int x) {

8. return 1.0;

9. }

10. }

What is the result?

A. An exception is thrown at runtime.

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

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

D. Compilation succeeds and no runtime errors with class A occur.

Answer: C

Q86. DRAG DROP

Click the Task button.

Answer:

Q87. Given:

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

12. try {

13. args = null;

14. args[0] = "test";

15. System.out.println(args[0]);

16. } catch (Exception ex) {

17. System.out.println("Exception");

18. } catch (NullPointerException npe) {

19. System.out.println("NullPointerException");

20. }

21. }

What is the result?

A. test

B. Exception

C. Compilation fails.

D. NullPointerException

Answer: C

Q88. Given:

10. class Line {

11. public class Point { public int x,y;}

12. public Point getPoint() { return new Point(); }

13. }

14. class Triangle {

15. public Triangle() {

16. // insert code here

17. }

18. }

Which code, inserted at line 16, correctly retrieves a local instance of a Point object?

A. Point p = Line.getPoint();

B. Line.Point p = Line.getPoint();

C. Point p = (new Line()).getPoint();

D. Line.Point p = (new Line()).getPoint();

Answer: D

Q89. Which two statements are true? (Choose two.)

A. It is possible for more than two threads to deadlock at once.

B. The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state.

C. Deadlocked threads release once their sleep() method's sleep duration has expired.

D. Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are used incorrectly.

E. It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly.

F. If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield().

Answer: AF

Q90. Given:

10. interface Data { public void load(); }

11. abstract class Info { public abstract void load(); }

Which class correctly uses the Data interface and Info class?

A. public class Employee extends Info implements Data { public void load() { /*do something*/ }

}

B. public class Employee implements Info extends Data { public void load() { /*do something*/ }

}

C. public class Employee extends Info implements Data { public void load(){ /*do something*/ }

public void Info.load(){ /*do something*/ }

}

D. public class Employee implements Info extends Data { public void Data.load(){ /*do something*/ }

public void load(){ /*do something*/ }

}

E. public class Employee implements Info extends Data { public void load(){ /*do something*/ }

public void Info.load(){ /*do something*/ }

}

F. public class Employee extends Info implements Data{

public void Data.load() { /*do something*/ }

public void Info.load() { /*do something*/ }

}

Answer: A