[Free] 2018(Jan) EnsurePass Testinsides Oracle 1z0-851 Dumps with VCE and PDF 1-10

By | January 25, 2018

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:

  1. public static int sum(List list) {

  2. int sum = 0;

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

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

  5. 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.)

  1. Remove line 14.

  2. Replace line 14 with quot;int i = iter.next();quot;.

  3. Replace line 13 with quot;for (int i : intList) {quot;.

  4. Replace line 13 with quot;for (Iterator iter : intList) {quot;.

  5. Replace the method declaration with quot;sum(Listlt;intgt; intList)quot;.

  6. 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?

  1. java.util.Queue

  2. java.util.ArrayList

  3. java.util.LinearList

  4. java.util.LinkedList

Answer: D

Question No: 3 – (Topic 1)

Given:

  1. // insert code here

  2. private N min, max;

  3. public N getMin() { return min; }

  4. public N getMax() { return max; }

  5. public void add(N added) {

  6. if (min == null || added.doubleValue() lt; min.doubleValue())

  7. min = added;

  8. if (max == null || added.doubleValue() gt; max.doubleValue())

  9. max = added;

20. }

21. }

Which two, inserted at line 11, will allow the code to compile? (Choose two.)

  1. public class MinMaxlt;?gt; {

  2. public class MinMaxlt;? extends Numbergt; {

  3. public class MinMaxlt;N extends Objectgt; {

  4. public class MinMaxlt;N extends Numbergt; {

  5. public class MinMaxlt;? extends Objectgt; {

  6. public class MinMaxlt;N extends Integergt; {

Answer: D,F

Question No: 4 – (Topic 1)

Given:

  1. import java.util.*;

  2. public class Explorer2 {

  3. public static void main(String[] args) {

  4. TreeSetlt;Integergt; s = new TreeSetlt;Integergt;();

  5. 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?

  1. Compilation fails.

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

    1. public class Score implements Comparablelt;Scoregt; {

    2. private int wins, losses;

    3. public Score(int w, int l) { wins = w; losses = l; }

    4. public int getWins() { return wins; }

    5. public int getLosses() { return losses; }

    6. public String toString() {

    7. return quot;lt;quot; wins quot;,quot; losses quot;gt;quot;; 8. }

  1. // insert code here

    10. }

    Which method will complete this class?

    1. public int compareTo(Object o){/*more code here*/}

    2. public int compareTo(Score other){/*more code here*/}

    3. public int compare(Score s1,Score s2){/*more code here*/}

    4. public int compare(Object o1,Object o2){/*more code here*/}

Answer: B

Question No: 6 – (Topic 1)

Given:

  1. public class Person {

  2. private name;

  3. public Person(String name) {

  4. this.name = name;

15. }

  1. public int hashCode() {

  2. return 420;

18. }

19. }

Which statement is true?

  1. The time to find the value from HashMap with a Person key depends on the size of the map.

  2. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.

  3. Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.

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

  1. import java.util.*;

  2. public class SortOf {

  3. public static void main(String[] args) {

  4. ArrayListlt;Integergt; a = new ArrayListlt;Integergt;(); 9. a.add(1); a.add(5); a.add(3);

11. Collections.sort(a);

12. a.add(2);

  1. Collections.reverse(a);

  2. 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]

  1. Compilation fails.

  2. An exception is thrown at runtime.

Answer: C

Question No: 8 – (Topic 1)

Given

  1. public interface Status {

  2. /* insert code here */ int MY_VALUE = 10;

  3. } Which three are valid on line 12?

(Choose three.)

  1. final

  2. static

  3. native

  4. public

  5. private

  6. abstract

  7. protected

Answer: A,B,D

Question No: 9 – (Topic 1)

Given:

  1. class Atom {

  2. Atom() { System.out.print(quot;atom quot;); } 7. }

  1. class Rock extends Atom {

  2. Rock(String type) { System.out.print(type); }

10. }

  1. public class Mountain extends Rock {

  2. Mountain() {

  3. super(quot;granite quot;);

  4. new Rock(quot;granite quot;);

15. }

16. public static void main(String[] a) { new Mountain(); }

17. }

What is the result?

  1. Compilation fails.

  2. atom granite

  3. granite granite

  4. atom granite granite

  5. An exception is thrown at runtime.

  6. atom granite atom granite

Answer: F

Question No: 10 – (Topic 1)

Click the Exhibit button. Which three statements are true? (Choose three.)

Ensurepass 2018 PDF and VCE

  1. Compilation fails.

  2. The code compiles and the output is 2.

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

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

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

  6. 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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.