Want to know Testking 1Z0-851 Exam practice test features? Want to lear more about Oracle Java Standard Edition 6 Programmer Certified Professional Exam certification experience? Study Tested Oracle 1Z0-851 answers to Rebirth 1Z0-851 questions at Testking. Gat a success with an absolute guarantee to pass Oracle 1Z0-851 (Java Standard Edition 6 Programmer Certified Professional Exam) test on your first attempt.

2016 Oct scjp 1z0-851:

Q41. Given:

11. public enum Title {

12. MR("Mr."), MRS("Mrs."), MS("Ms.");

13. private final String title;

14. private Title(String t) { title = t; }

15. public String format(String last, String first) {

16. return title + " " + first + " " + last;

17. }

18. }

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

20. System.out.println(Title.MR.format("Doe", "John"));

21. }

What is the result?

A. Mr. John Doe

B. An exception is thrown at runtime.

C. Compilation fails because of an error in line 12.

D. Compilation fails because of an error in line 15.

E. Compilation fails because of an error in line 20.

Answer: A


Q42. Given:

1. public class Score implements Comparable<Score> {

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 "<" + wins + "," + losses + ">";

8. }

9. // insert code here

10. }

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


Q43. Given:

10. interface A { void x(); }

11. class B implements A { public void x() {} public void y() {} }

12. class C extends B { public void x() {} }

And:

20. java.util.List<A> list = new java.util.ArrayList<A>();

21. list.add(new B());

22. list.add(new C());

23. for (A a : list) {

24. a.x();

25. a.y();

26. }

What is the result?

A. The code runs with no output.

B. An exception is thrown at runtime.

C. Compilation fails because of an error in line 20.

D. Compilation fails because of an error in line 21.

E. Compilation fails because of an error in line 23.

F. Compilation fails because of an error in line 25.

Answer: F


Q44. Given:

11. public class Person {

12. private String name;

13. public Person(String name) {

14. this.name = name;

15. }

16. public boolean equals(Object o) {

17. if ( ! ( o instanceof Person) ) return false;

18. Person p = (Person) o;

19. return p.name.equals(this.name);

20. }

21. }

Which statement is true?

A. Compilation fails because the hashCode method is not overridden.

B. A HashSet could contain multiple Person objects with the same name.

C. All Person objects will have the same hash code because the hashCode method is not overridden.

D. If a HashSet contains more than one Person object with name="Fred", then removing another Person, also with name="Fred", will remove them all.

Answer: B


Q45. Given:

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

12. Integer i = new Integer(1) + new Integer(2);

13. switch(i) {

14. case 3: System.out.println("three"); break;

15. default: System.out.println("other"); break;

16. }

17. }

What is the result?

A. three

B. other

C. An exception is thrown at runtime.

D. Compilation fails because of an error on line 12.

E. Compilation fails because of an error on line 13.

F. Compilation fails because of an error on line 15.

Answer: A


Improved 1z0-851 exam details:

Q46. A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)

A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.

B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..

C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar/Paper.class.

D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar.

E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/

Paper Book.java.

F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar

Book.java

G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/

myLib.jar Book.java

Answer: BDG


Q47. A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)

A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.

B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..

C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar/Paper.class.

D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/

myLib.jar.

E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp /foo/myLib.jar/

Paper Book.java.

F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar

Book.java

G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/

myLib.jar Book.java

Answer: BDG


Q48. Given a valid DateFormat object named df, and

16. Date d = new Date(0L);

17. String ds = "December 15, 2004";

18. // insert code here What updates d's value with the date represented by ds?

A. 18. d = df.parse(ds);

B. 18. d = df.getDate(ds);

C. 18. try {

19. d = df.parse(ds);

20. } catch(ParseException e) { };

D. 18. try {

19. d = df.getDate(ds);

20. } catch(ParseException e) { };

Answer: C


Q49. Given:

1. public class Threads4 {

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

3. new Threads4().go();

4. }

5. public void go() {

6. Runnable r = new Runnable() {

7. public void run() {

8. System.out.print("foo");

9. }

10. };

11. Thread t = new Thread(r);

12. t.start();

13. t.start();

14. }

15. }

What is the result?

A. Compilation fails.

B. An exception is thrown at runtime.

C. The code executes normally and prints "foo".

D. The code executes normally, but nothing is printed.

Answer: B


Q50. 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: E