web analytics

Braindump2go Free Microsoft Dumps Questions Collection

Latest Real Exam Questions and Answers to help you pass Microsoft and other Hot exam 100%!

2014 Latest Oracle 1Z0-851 Exam Demo Free Download!

QUESTION 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;
}
return sum;
}
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: ACF

QUESTION 2
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: D

QUESTION 3
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() < min.doubleValue())
min = added;
if (max == null || added.doubleValue() > max.doubleValue())
max = added;
}
}
Which two, inserted at line 11, will allow the code to compile? (Choose two.)

A.    public class MinMax<?> {
B.    public class MinMax<? extends Number> {
C.    public class MinMax<N extends Object> {
D.    public class MinMax<N extends Number> {
E.    public class MinMax<? extends Object> {
F.    public class MinMax<N extends Integer> {

Answer: DF

QUESTION 4
Given:
import java.util.*;
public class Explorer2 {
public static void main(String[] args) {
TreeSet<Integer> s = new TreeSet<Integer>();
TreeSet<Integer> subs = new TreeSet<Integer>();
for(int i = 606; i < 613; i++)
if(i%2 == 0) s.add(i);
subs = (TreeSet)s.subSet(608, true, 611, true);
s.add(629);
System.out.println(s + " " + subs);
}
}
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: E

QUESTION 5
Given:
public class Score implements Comparable<Score> {
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 "<" + wins + "," + losses + ">";
}
// insert code here
}
Which method will complete this class?

A.    public int compareTo(Object o){/*more code here*/}
B.    public int compareTo(Score other){/*more code here*/}
C.    public int compare(Score s1,Score s2){/*more code here*/}
D.    public int compare(Object o1,Object o2){/*more code here*/}

Answer: B

QUESTION 6
Given:
public class Person {
private name;
public Person(String name) {
this.name = name;
}
public int hashCode() {
return 420;
}
}
Which statement is true?

A.    The time to find the value from HashMap with a Person key depends on the size of the map.
B.    Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
C.    Inserting a second Person object into a HashSet will cause the first Person object to be removed
as a duplicate.
D.    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 7
Given:
import java.util.*;
public class SortOf {
public static void main(String[] args) {
ArrayList<Integer> a = new ArrayList<Integer>();
a.add(1); a.add(5); a.add(3);
Collections.sort(a);
a.add(2);
Collections.reverse(a);
System.out.println(a);
}
}
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]
F.    Compilation fails.
H.    An exception is thrown at runtime.

Answer: C

QUESTION 8
Given
public interface Status {
/* insert code here */ int MY_VALUE = 10;
}
Which three are valid on line 12? (Choose three.)

A.    final
B.    static
C.    native
D.    public
E.    private
F.    abstract
G.    protected

Answer: ABD

QUESTION 9
Given:
class Atom {
Atom() { System.out.print("atom "); }
}
class Rock extends Atom {
Rock(String type) { System.out.print(type); }
}
public class Mountain extends Rock {
Mountain() {
super("granite ");
new Rock("granite ");
}
public static void main(String[] a) { new Mountain(); }
}
What is the result?

A.    Compilation fails.
B.    atom granite
C.    granite granite
D.    atom granite granite
E.    An exception is thrown at runtime.
F.    atom granite atom granite

Answer: F

QUESTION 10
Click the Exhibit button. Which three statements are true? (Choose three.)
 clip_image001
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: BEF

QUESTION 11
Given:
class Line {
public class Point { public int x,y;}
public Point getPoint() { return new Point(); }
}
class Triangle {
public Triangle() {
// insert code here
}
}
Which code, inserted at line 16, correctly retrieves a local instance of a Point object?

A.    Point p = Line.getPoint();
B.    Line.Point p = Line.getPoint();
C.    Point p = (new Line()).getPoint();
D.    Line.Point p = (new Line()).getPoint();

Answer: D

QUESTION 12
Given:
class Alpha {
public void foo() { System.out.print("Afoo "); }
}
public class Beta extends Alpha {
public void foo() { System.out.print("Bfoo "); }
public static void main(String[] args) {
Alpha a = new Beta();
Beta b = (Beta)a;
a.foo();
b.foo();
}
}
What is the result?

A.    Afoo Afoo
B.    Afoo Bfoo
C.    Bfoo Afoo
D.    Bfoo Bfoo
E.    Compilation fails.
H.    An exception is thrown at runtime.

Answer: D

QUESTION 13
Click the Exhibit button. Which statement is true about the classes and interfaces in the exhibit?
 clip_image001[4]

A.    Compilation will succeed for all classes and interfaces.
B.    Compilation of class C will fail because of an error in line 2.
C.    Compilation of class C will fail because of an error in line 6.
D.    Compilation of class AImpl will fail because of an error in line 2.

Answer: C

QUESTION 14
Which two code fragments correctly create and initialize a static array of int elements? (Choose two.)

A.    static final int[] a = { 100,200 };
B.    static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
C.    static final int[] a = new int[2]{ 100,200 };
D.    static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }

Answer: AB

QUESTION 15
Given:
interface Foo { int bar(); }
public class Sprite {
public int fubar( Foo foo ) { return foo.bar(); }
public void testFoo() {
fubar(
// insert code here
);
}
}
Which code, inserted at line 15, allows the class Sprite to compile?

A.    Foo { public int bar() { return 1; }
B.    new Foo { public int bar() { return 1; }
C.    new Foo() { public int bar() { return 1; }
D.    new class Foo { public int bar() { return 1; }

Answer: C

QUESTION 16
Given:
class Alligator {
public static void main(String[] args) {
int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
int [][]y = x;
System.out.println(y[2][1]);
}
}
What is the result?

A.    2
B.    3
C.    4
D.    6
E.    7
F.    Compilation fails.

Answer: E
Passing your Oracle 1Z0-851 Exam by using the latest 1Z0-851 Exam Dump Full Version: http://www.braindump2go.com/1z0-851.html

, , , ,

Comments are currently closed.