Guaranteed of 1Z0-852 free question materials and free demo for Oracle certification for IT candidates, 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 Oct 1Z0-852 free exam questions

Q11. Given: 

12.

 import java.util.*; 

13.

 public class Explorer3 { 

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.

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

Explanation: 


Q12. Given: 

1.

 class Alligator { 

2.

 public static void main(String[] args) { 

3.

 int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}}; 

4.

 int [][]y = x; 

5.

 System.out.println(y[2][1]); 

6.

 } 

7.

 } 

What is the result? 

A. 2 

B. 3 

C. 4 

D. 6 

E. 7 

F. Compilation fails. 

Answer:

Explanation: 


Q13. Click the Exhibit button. 

Which three statements are true? (Choose three.) 

A. Compilation fails. 

B. The code compiles and the output is 2. 

C. If lines 16, 17 and 18 were removed, compilation would fail. 

D. If lines 24, 25 and 26 were removed, compilation would fail. 

E. If lines 16, 17 and 18 were removed, the code would compile and the output would be 2. 

F. If lines 24, 25 and 26 were removed, the code would compile and the output would be 1. 

Answer: B,E,F 

Explanation: 


Q14. Given: 

11.

 public class PingPong implements Runnable { 

12.

 synchronized void hit(long n) { 

13.

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

14.

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

15.

 } 

16.

 public static void main(String[] args) { 

17.

 new Thread(new PingPong()).start(); 

18.

 new Thread(new PingPong()).start(); 

19.

 } 

20.

 public void run() { 

21.

 hit(Thread.currentThread().getId()); 

22.

 } 

23.

 } 

Which two statements are true? (Choose two.) 

A. The output could be 8-1 7-2 8-2 7-1 

B. The output could be 7-1 7-2 8-1 6-1 

C. The output could be 8-1 7-1 7-2 8-2 

D. The output could be 8-1 8-2 7-1 7-2 

Answer: C,D 

Explanation: 


Q15. Given: 

1.

 public class TestOne implements Runnable { 

2.

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

3.

 Thread t = new Thread(new TestOne()); 

4.

 t.start(); 

5.

 System.out.print("Started"); 

6.

 t.join(); 

7.

 System.out.print("Complete"); 

8.

 } 

9.

 public void run() { 

10.

 for (int i = 0; i < 4; i++) { 

11.

 System.out.print(i); 

12.

 } 

13.

 } 

14.

 } 

What can be a result? 

A. Compilation fails. 

B. An exception is thrown at runtime. 

C. The code executes and prints "StartedComplete". 

D. The code executes and prints "StartedComplete0123". 

E. The code executes and prints "Started0123Complete". 

Answer:

Explanation: 


Renovate 1Z0-852 latest exam:

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


Q17. Given: 

5.

 import java.util.Date; 

6.

 import java.text.DateFormat; 

21.

 DateFormat df 

22.

 Date date = new Date(); 

23.

 // insert code here 

24.

 String s = df.format(date); 

Which code fragment, inserted at line 23, allows the code to compile? 

A. df = new DateFormat(); 

B. df = Date.getFormat(); 

C. df = date.getFormat(); 

D. df = DateFormat.getFormat(); 

E. df = DateFormat.getInstance(); 

Answer:

Explanation: 


Q18. Given: 

11.

 public void testIfA() { 

12.

 if (testIfB("True")) { 

13.

 System.out.println("True"); 

14.

 } else { 

15.

 System.out.println("Not true"); 

16.

 } 

17.

 } 

18.

 public Boolean testIfB(String str) { 

19.

 return Boolean.valueOf(str); 

20.

 } 

What is the result when method testIfA is invoked? 

A. True 

B. Not true 

C. An exception is thrown at runtime. 

D. Compilation fails because of an error at line 12. 

E. Compilation fails because of an error at line 19. 

Answer:

Explanation: 


Q19. Given: 

1.

 public class Donkey2 { 

2.

 public static void main(String[] args) { 

3.

 boolean assertsOn = true; 

4.

 assert (assertsOn) : assertsOn = true; 

5.

 if(assertsOn) { 

6.

 System.out.println("assert is on"); 

7.

 } 

8.

 } 

9.

 } 

If class Donkey is invoked twice, the first time without assertions enabled, and the second timewith assertions enabled, what are the results? 

A. no output 

B. no output 

assert is on 

C. assert is on 

D. no output 

An AssertionError is thrown. 

E. assert is on 

An AssertionError is thrown. 

Answer:

Explanation: 


Q20. Given: 

11.

 public class Barn { 

12.

 public static void main(String[] args) { 

13.

 new Barn().go("hi", 1); 

14.

 new Barn().go("hi", "world", 2); 

15.

 } 

16.

 public void go(String... y, int x) { 

17.

 System.out.print(y[y.length - 1] + " "); 

18.

 } 

19.

 } 

What is the result? 

A. hi hi 

B. hi world 

C. world world 

D. Compilation fails. 

E. An exception is thrown at runtime. 

Answer:

Explanation: 

74. Given: 

11.

 class Alpha { 

12.

 public void foo() { System.out.print("Afoo "); } 

13.

 } 

14.

 public class Beta extends Alpha { 

15.

 public void foo() { System.out.print("Bfoo "); } 

16.

 public static void main(String[] args) { 

17.

 Alpha a = new Beta(); 

18.

 Beta b = (Beta)a; 

19.

 a.foo(); 

20.

 b.foo(); 

21.

 } 

22.

 } 

What is the result? 

A. Afoo Afoo 

B. Afoo Bfoo 

C. Bfoo Afoo 

D. Bfoo Bfoo 

E. Compilation fails. 

F. An exception is thrown at runtime. 

Answer:

Explanation: