Real of 1Z0-852 training materials and forum for Oracle certification for examinee, Real Success Guaranteed with Updated 1Z0-852 pdf dumps vce Materials. 100% PASS Java Standard Edition 6 Programmer Certified Professional Upgrade Exam exam Today!

2016 Nov 1Z0-852 practice question

Q51. Which three will compile and run without exception? (Choose three.) 

A. private synchronized Object o; 

B. void go() { 

synchronized() { /* code here */ } 

C. public synchronized void go() { /* code here */ } 

D. private synchronized(this) void go() { /* code here */ } 

E. void go() { 

synchronized(Object.class) { /* code here */ } 

F. void go() { 

Object o = new Object(); 

synchronized(o) { /* code here */ } 

Answer: C,E,F 

Explanation: 


Q52. Given the following directory structure: And the following command line invocation: 

javac -d classes source/Utils.java 

Assume the current directory is bigProject, what is the result? 

A. If the compile is successful, Utils.class is added to the source directory. 

B. The compiler returns an invalid flag error. 

C. If the compile is successful, Utils.class is added to the classes directory. 

D. If the compile is successful, Utils.class is added to the bigProject directory. 

Answer:

Explanation: 


Q53. Given that the elements of a PriorityQueue are ordered according to natural ordering, and: 

2.

 import java.util.*; 

3.

 public class GetInLine { 

4.

 public static void main(String[] args) { 

5.

 PriorityQueue<String> pq = new PriorityQueue<String>(); 

6.

 pq.add("banana"); 

7.

 pq.add("pear"); 

8.

 pq.add("apple"); 

9.

 System.out.println(pq.poll() + " " + pq.peek()); 

10.

 } 

11.

 } 

What is the result? 

A. apple pear 

B. banana pear 

C. apple apple 

D. apple banana 

E. banana banana 

Answer:

Explanation: 


Q54. A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command: 

java games.cards.Poker 

What allows the user to do this? 

A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java 

B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar 

C. Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar 

D. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java 

E. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/*.jar 

F. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.jar 

Answer:

Explanation: 

78. Click the Exhibit button. 

Given the fully-qualified class names: 

com.foo.bar.Dog com.foo.bar.blatz.Book com.bar.Car com.bar.blatz.Sun 

Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM? 

A. Jar A 

B. Jar B 

C. Jar C 

D. Jar D 

E. Jar E 

Answer:

Explanation: 


Regenerate 1Z0-852 free draindumps:

Q55. Given: 

1.

 class TestException extends Exception { } 

2.

 class A { 

3.

 public String sayHello(String name) throws TestException { 

4.

 if(name == null) throw new TestException(); 

5.

 return "Hello " + name; 

6.

 } 

7.

 } 

8.

 public class TestA { 

9.

 public static void main(String[] args) { 

10.

 new A().sayHello("Aiko"); 

11.

 } 

12.

 } 

Which statement is true? 

A. Compilation succeeds. 

B. Class A does not compile. 

C. The method declared on line 9 cannot be modified to throw TestException. 

D. TestA compiles if line 10 is enclosed in a try/catch block that catches TestException. 

Answer:

Explanation: 


Q56. Given: 

11.

 class PingPong2 { 

12.

 synchronized void hit(long n) { 

13.

 for(int i = 1; i < 3; i++) 

14.

 System.out.print(n + "-" + i + " "); 

15.

 } 

16.

 } 

17.

 public class Tester implements Runnable { 

18.

 static PingPong2 pp2 = new PingPong2(); 

19.

 public static void main(String[] args) { 

20.

 new Thread(new Tester()).start(); 

21.

 new Thread(new Tester()).start(); 

22.

 } 

23.

 public void run() { pp2.hit(Thread.currentThread().getId()); } 

24.

 } 

Which statement is true? 

A. The output could be 5-1 6-1 6-2 5-2 

B. The output could be 6-1 6-2 5-1 5-2 

C. The output could be 6-1 5-2 6-2 5-1 

D. The output could be 6-1 6-2 5-1 7-1 

Answer:

Explanation: 


Q57. Given: 

11.

 public interface A { public void m1(); } 

12. 

13.

 class B implements A { } 

14.

 class C implements A { public void m1() { } } 

15.

 class D implements A { public void m1(int x) { } } 

16.

 abstract class E implements A { } 

17.

 abstract class F implements A { public void m1() { } } 

18.

 abstract class G implements A { public void m1(int x) { } } 

What is the result? 

A. Compilation succeeds. 

B. Exactly one class does NOT compile. 

C. Exactly two classes do NOT compile. 

D. Exactly four classes do NOT compile. 

E. Exactly three classes do NOT compile. 

Answer:

Explanation: 


Q58. 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:

Explanation: 

15. 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:

Explanation: 


Q59. Given: 

public class NamedCounter { 

private final String name; 

private int count; 

public NamedCounter(String name) { this.name = name; } 

public String getName() { return name; } 

public void increment() { count++; } 

public int getCount() { return count; } 

public void reset() { count = 0; 

Which three changes should be made to adapt this class to be used safely by multiple threads? (Choose three.) 

A. declare reset() using the synchronized keyword 

B. declare getName() using the synchronized keyword 

C. declare getCount() using the synchronized keyword 

D. declare the constructor using the synchronized keyword 

E. declare increment() using the synchronized keyword 

Answer: A,C,E 

Explanation: