1Z0-851 | Refresh 1Z0-851 Exam Study Guides With New Update Exam Questions


Q21. Click the Exhibit button. What is the result?

A. go in Goban

go in Sente

B. go in Sente

go in Goban

C. go in Sente

go in Goban

D. go in Goban

go in Sente

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

Answer: C

Q22. Given:

1. public class Base {

2. public static final String FOO = "foo";

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

4. Base b = new Base();

5. Sub s = new Sub();

6. System.out.print(Base.FOO);

7. System.out.print(Sub.FOO);

8. System.out.print(b.FOO);

9. System.out.print(s.FOO);

10. System.out.print(((Base)s).FOO);

11. } }

12. class Sub extends Base {public static final String FOO="bar";}

What is the result?

A. foofoofoofoofoo

B. foobarfoobarbar

C. foobarfoofoofoo

D. foobarfoobarfoo

E. barbarbarbarbar

F. foofoofoobarbar

G. foofoofoobarfoo

Answer: D

Q23. Given:

1. public class GC {

2. private Object o;

3. private void doSomethingElse(Object obj) { o = obj; }

4. public void doSomething() {

5. Object o = new Object();

6. doSomethingElse(o);

7. o = new Object();

8. doSomethingElse(null);

9. o = null;

10. }

11. }

When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?

A. Line 5

B. Line 6

C. Line 7

D. Line 8

E. Line 9

F. Line 10

Answer: D

Q24. Given:

12. NumberFormat nf = NumberFormat.getInstance();

13. nf.setMaximumFractionDigits(4);

14. nf.setMinimumFractionDigits(2);

15. String a = nf.format(3.1415926);

16. String b = nf.format(2);

Which two statements are true about the result if the default locale is Locale.US? (Choose two.)

A. The value of b is 2.

B. The value of a is 3.14.

C. The value of b is 2.00.

D. The value of a is 3.141.

E. The value of a is 3.1415.

F. The value of a is 3.1416.

G. The value of b is 2.0000.

Answer: CF

Q25. Given:

11. class ClassA {}

12. class ClassB extends ClassA {}

13. class ClassC extends ClassA {} and:

21. ClassA p0 = new ClassA();

22. ClassB p1 = new ClassB();

23. ClassC p2 = new ClassC();

24. ClassA p3 = new ClassB();

25. ClassA p4 = new ClassC();

Which three are valid? (Choose three.)

A. p0 = p1;

B. p1 = p2;

C. p2 = p4;

D. p2 = (ClassC)p1;

E. p1 = (ClassB)p3;

F. p2 = (ClassC)p4;

Answer: AEF

Q26. Given:

12. String csv = "Sue,5,true,3";

13. Scanner scanner = new Scanner( csv );

14. scanner.useDelimiter(",");

15. int age = scanner.nextInt();

What is the result?

A. Compilation fails.

B. After line 15, the value of age is 5.

C. After line 15, the value of age is 3.

D. An exception is thrown at runtime.

Answer: D

Q27. Given:

11. class Converter {

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

13. Integer i = args[0];

14. int j = 12;

15. System.out.println("It is " + (j==i) + " that j==i.");

16. }

17. }

What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?

A. It is true that j==i.

B. It is false that j==i.

C. An exception is thrown at runtime.

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

Answer: D

Q28. Given classes defined in two different files:

1. package util;

2. public class BitUtils {

3. public static void process(byte[] b) { /* more code here */ }

4. }

1. package app;

2. public class SomeApp {

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

4. byte[] bytes = new byte[256];

5. // insert code here

6. }

7. }

What is required at line 5 in class SomeApp to use the process method of BitUtils?

A. process(bytes);

B. BitUtils.process(bytes);

C. util.BitUtils.process(bytes);

D. SomeApp cannot use methods in BitUtils.

E. import util.BitUtils.*; process(bytes);

Answer: C

Q29. Given a pre-generics implementation of a method:

11. public static int sum(List list) {

12. int sum = 0;

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

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

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

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

Q30. Given:

10. class One {

11. public One foo() { return this; }

12. }

13. class Two extends One {

14. public One foo() { return this; }

15. }

16. class Three extends Two {

17. // insert method here

18. }

Which two methods, inserted individually, correctly complete the Three class? (Choose two.)

A. public void foo() {}

B. public int foo() { return 3; }

C. public Two foo() { return this; }

D. public One foo() { return this; }

E. public Object foo() { return this; }

Answer: CD