Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-852
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-852.html
Java Standard Edition 6 Programmer Certified Professional Upgrade Exam
Question No: 41 DRAG DROP
Click the Task button.
Answer:
Question No: 42
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?
-
java.util.Queue
-
java.util.ArrayList
-
java.util.LinearList
-
java.util.LinkedList
Answer: D
Question No: 43
Given a pre-generics implementation of a method:
-
public static int sum(List list) {
-
int sum = 0;
-
for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
-
int i = ((Integer)iter.next()).intValue();
-
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.)
-
Remove line 14.
-
Replace line 14 with quot;int i = iter.next();quot;.
-
Replace line 13 with quot;for (int i : intList) {quot;.
-
Replace line 13 with quot;for (Iterator iter : intList) {quot;.
-
Replace the method declaration with quot;sum(Listlt;intgt; intList)quot;.
-
Replace the method declaration with quot;sum(Listlt;Integergt; intList)quot;.
Answer: A,C,F
Question No: 44
Given:
-
import java.util.*;
-
public class Explorer2 {
-
public static void main(String[] args) {
-
TreeSetlt;Integergt; s = new TreeSetlt;Integergt;();
-
TreeSetlt;Integergt; subs = new TreeSetlt;Integergt;(); 17. for(int i = 606; i lt; 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 quot; quot; subs);
22. }
23. }
What is the result?
-
Compilation fails.
-
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: E
Question No: 45
Given that the elements of a PriorityQueue are ordered according to natural ordering, and:
-
import java.util.*;
-
public class GetInLine {
-
public static void main(String[] args) {
-
PriorityQueuelt;Stringgt; pq = new PriorityQueuelt;Stringgt;();
-
pq.add(quot;bananaquot;);
-
pq.add(quot;pearquot;);
-
pq.add(quot;applequot;);
-
System.out.println(pq.poll() quot; quot; pq.peek());
10. }
11. }
What is the result?
-
apple pear
-
banana pear
-
apple apple
-
apple banana
-
banana banana
Answer: D
Question No: 46
Given:
-
import java.util.*;
-
public class SortOf {
-
public static void main(String[] args) {
-
ArrayListlt;Integergt; a = new ArrayListlt;Integergt;();
9. a.add(1); a.add(5); a.add(3);
11. Collections.sort(a);
12. a.add(2);
-
Collections.reverse(a);
-
System.out.println(a);
15. }
16. }
What is the result?
A. [1, 2, 3, 5]
B. [2, 1, 3, 5]
C. [2, 5, 3, 1]
D. [5, 3, 2, 1]
E. [1, 3, 5, 2]
-
-
Compilation fails.
-
An exception is thrown at runtime.
-
Answer: C
Question No: 47
Given:
-
import java.util.*;
-
public class G1 {
-
public void takeList(Listlt;? extends Stringgt; list) {
-
// insert code here 7. }
8. }
Which three code fragments, inserted independently at line 6, will compile? (Choose three.)
-
list.add(quot;fooquot;);
-
Object o = list;
-
String s = list.get(0);
-
list = new ArrayListlt;Stringgt;();
-
list = new ArrayListlt;Objectgt;();
Answer: B,C,D
Question No: 48
Given:
-
import java.util.*; 2.
-
-
-
public class LetterASort{
-
public static void main(String[] args) {
-
ArrayListlt;Stringgt; strings = new ArrayListlt;Stringgt;();
-
strings.add(quot;aAaAquot;);
-
strings.add(quot;AaAquot;);
-
strings.add(quot;aAaquot;);
-
strings.add(quot;AAaaquot;);
-
Collections.sort(strings);
-
for (String s : strings) { System.out.print(s quot; quot;); }
12. }
13. }
What is the result?
-
Compilation fails.
-
aAaA aAa AAaa AaA
-
AAaa AaA aAa aAaA
-
AaA AAaa aAaA aAa
-
aAa AaA aAaA AAaa
-
An exception is thrown at runtime.
Answer: C
Question No: 49
Given:
-
import java.util.*;
-
public class Example {
-
public static void main(String[] args) {
-
// insert code here
-
set.add(new Integer(2));
-
set.add(new Integer(1));
-
System.out.println(set); 8. }
9. }
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
-
Set set = new TreeSet();
-
Set set = new HashSet();
-
Set set = new SortedSet();
-
List set = new SortedList();
-
Set set = new LinkedHashSet();
-
-
Answer: A
Question No: 50 DRAG DROP
Click the Task button.
Answer:
100% Ensurepass Free Download!
–Download Free Demo:1z0-852 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-852 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |
100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF