Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-851
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-851.html
Java Standard Edition 6 Programmer Certified Professional Exam
Question No: 1 – (Topic 1)
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: 2 – (Topic 1)
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: 3 – (Topic 1)
Given:
-
// insert code here
-
private N min, max;
-
public N getMin() { return min; }
-
public N getMax() { return max; }
-
public void add(N added) {
-
if (min == null || added.doubleValue() lt; min.doubleValue())
-
min = added;
-
if (max == null || added.doubleValue() gt; max.doubleValue())
-
max = added;
20. }
21. }
Which two, inserted at line 11, will allow the code to compile? (Choose two.)
-
public class MinMaxlt;?gt; {
-
public class MinMaxlt;? extends Numbergt; {
-
public class MinMaxlt;N extends Objectgt; {
-
public class MinMaxlt;N extends Numbergt; {
-
public class MinMaxlt;? extends Objectgt; {
-
public class MinMaxlt;N extends Integergt; {
Answer: D,F
Question No: 4 – (Topic 1)
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: 5 – (Topic 1)
Given:
-
public class Score implements Comparablelt;Scoregt; {
-
private int wins, losses;
-
public Score(int w, int l) { wins = w; losses = l; }
-
public int getWins() { return wins; }
-
public int getLosses() { return losses; }
-
public String toString() {
-
return quot;lt;quot; wins quot;,quot; losses quot;gt;quot;; 8. }
-
-
// insert code here
10. }
Which method will complete this class?
-
public int compareTo(Object o){/*more code here*/}
-
public int compareTo(Score other){/*more code here*/}
-
public int compare(Score s1,Score s2){/*more code here*/}
-
public int compare(Object o1,Object o2){/*more code here*/}
-
Answer: B
Question No: 6 – (Topic 1)
Given:
-
public class Person {
-
private name;
-
public Person(String name) {
-
this.name = name;
15. }
-
public int hashCode() {
-
return 420;
18. }
19. }
Which statement is true?
-
The time to find the value from HashMap with a Person key depends on the size of the map.
-
Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
-
Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
-
The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
Answer: A
Question No: 7 – (Topic 1)
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: 8 – (Topic 1)
Given
-
public interface Status {
-
/* insert code here */ int MY_VALUE = 10;
-
} Which three are valid on line 12?
(Choose three.)
-
final
-
static
-
native
-
public
-
private
-
abstract
-
protected
Answer: A,B,D
Question No: 9 – (Topic 1)
Given:
-
class Atom {
-
Atom() { System.out.print(quot;atom quot;); } 7. }
-
class Rock extends Atom {
-
Rock(String type) { System.out.print(type); }
10. }
-
public class Mountain extends Rock {
-
Mountain() {
-
super(quot;granite quot;);
-
new Rock(quot;granite quot;);
15. }
16. public static void main(String[] a) { new Mountain(); }
17. }
What is the result?
-
Compilation fails.
-
atom granite
-
granite granite
-
atom granite granite
-
An exception is thrown at runtime.
-
atom granite atom granite
Answer: F
Question No: 10 – (Topic 1)
Click the Exhibit button. Which three statements are true? (Choose three.)
-
Compilation fails.
-
The code compiles and the output is 2.
-
If lines 16, 17 and 18 were removed, compilation would fail.
-
If lines 24, 25 and 26 were removed, compilation would fail.
-
If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.
-
If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.
Answer: B,E,F
100% Ensurepass Free Download!
–Download Free Demo:1z0-851 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-851 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