1Z0-852 | Guaranteed Oracle 1Z0-852 exam dumps


Q21. RAG DROP 

Click the Task button. 

Answer: 

Q22. RAG DROP 

Click the Task button. 

Answer: 

94. Given: 

1.

 public class Target { 

2.

 private int i = 0; 

3.

 public int addOne(){ 

4.

 return ++i; 

5.

 } 

6.

 } 

And: 

1.

 public class Client { 

2.

 public static void main(String[] args){ 

3.

 System.out.println(new Target().addOne()); 

4.

 } 

5.

 } 

Which change can you make to Target without affecting Client? 

A. Line 4 of class Target can be changed to return i++; 

B. Line 2 of class Target can be changed to private int i = 1; 

C. Line 3 of class Target can be changed to private int addOne(){ 

D. Line 2 of class Target can be changed to private Integer i = 0; 

Answer:

Explanation: 

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

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

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

Explanation: 

Q26. A programmer has an algorithm that requires a java.util.List that provides an efficient 

implementation of add(0, object), but does NOT need to support quick random access. What supports these requirements? 

A. java.util.Queue 

B. java.util.ArrayList 

C. java.util.LinearList 

D. java.util.LinkedList 

Answer:

Explanation: 

Q27. Given: 

11.

 String test = "Test A. Test B. Test C."; 

12.

 // insert code here 

13.

 String[] result = test.split(regex); 

Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"? 

A. String regex = ""; B. String regex = " "; C. String regex = ".*"; D. String regex = "\s"; 

E. String regex = "\.\s*"; 

F. String regex = "\w[ .] +"; 

Answer:

Explanation: 

18. Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: 

1.

 import java.io.*; 

2.

 public class Maker { 

3.

 public static void main(String[] args) { 

4.

 File dir = new File("dir"); 

5.

 File f = new File(dir, "f"); 

6.

 } 

7.

 } 

Which statement is true? 

A. Compilation fails. 

B. Nothing is added to the file system. 

C. Only a new file is created on the file system. 

D. Only a new directory is created on the file system. 

E. Both a new file and a new directory are created on the file system. 

Answer:

Explanation: 

Q28. Given a pre-generics implementation of a method: 

11.

 public static int sum(List list) { 

12.

 int sum = 0; 

13.

 for ( Iterator iter = list.iterator(); iter.hasNext(); ) { 

14.

 int i = ((Integer)iter.next()).intValue(); 

15.

 sum += i; 

16.

 } 

17.

 return sum; 

18.

 } 

What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.) 

A. Remove line 14. 

B. Replace line 14 with "int i = iter.next();". 

C. Replace line 13 with "for (int i : intList) {". 

D. Replace line 13 with "for (Iterator iter : intList) {". 

E. Replace the method declaration with "sum(List<int> intList)". 

F. Replace the method declaration with "sum(List<Integer> intList)". 

Answer: A,C,F 

Explanation: 

44. Given: 

12.

 import java.util.*; 

13.

 public class Explorer2 { 

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.

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

Q29. Given the following six method names: 

addListener 

addMouseListener 

setMouseListener 

deleteMouseListener 

removeMouseListener 

registerMouseListener How many of these method names follow JavaBean Listener naming rules? 

A. 1 

B. 2 

C. 3 

D. 4 

E. 5 

Answer:

Explanation: 

Q30. Given: 

10.

 interface Foo {} 

11.

 class Alpha implements Foo {} 

12.

 class Beta extends Alpha {} 

13.

 class Delta extends Beta { 

14.

 public static void main( String[] args ) { 

15.

 Beta x = new Beta(); 

16.

 // insert code here 

17.

 } 

18.

 } 

Which code, inserted at line 16, will cause a java.lang.ClassCastException? 

A. Alpha a = x; 

B. Foo f = (Delta)x; 

C. Foo f = (Alpha)x; 

D. Beta b = (Beta)(Alpha)x; 

Answer:

Explanation: