[Free] 2018(Jan) EnsurePass Dumpsleader Oracle 1z0-851 Dumps with VCE and PDF 21-30

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: 21 – (Topic 1)

Given:

  1. import java.util.Date;

  2. import java.text.DateFormat;

  1. DateFormat df;

  2. Date date = new Date();

  3. // insert code here

  4. String s = df.format(date);

Which code fragment, inserted at line 23, allows the code to compile?

  1. df = new DateFormat();

  2. df = Date.getFormat();

  3. df = date.getFormat();

  4. df = DateFormat.getFormat();

  5. df = DateFormat.getInstance();

    Answer: E

    Question No: 22 – (Topic 1)

    Given a class Repetition:

    1. package utils; 2.

  1. public class Repetition {

  2. public static String twice(String s) { return s s; }

  3. } and given another class Demo: 1. // insert code here 2.

  1. public class Demo {

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

  3. System.out.println(twice(quot;pizzaquot;)); 6. }

    7. }

    Which code should be inserted at line 1 of Demo.java to compile and run Demo to print quot;pizzapizzaquot;?

    1. import utils.*;

    2. static import utils.*;

    3. import utils.Repetition.*;

    4. static import utils.Repetition.*;

    5. import utils.Repetition.twice();

    6. import static utils.Repetition.twice;

    7. static import utils.Repetition.twice;

Answer: F

Question No: 23 – (Topic 1)

A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command: java -classpath

/test:/home/bob/downloads/*.jar games.Chess Bob#39;s CLASSPATH is set (at login time) to:

/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jar What is a possible location for the Chess.class file?

  1. /test/Chess.class

  2. /home/bob/Chess.class

  3. /test/games/Chess.class

  4. /usr/lib/games/Chess.class

  5. /home/bob/games/Chess.class

  6. inside jarfile /opt/java/lib/Games.jar (with a correct manifest)

  7. inside jarfile /home/bob/downloads/Games.jar (with a correct manifest)

Answer: C

Question No: 24 – (Topic 1)

Given:

  1. interface Animal { void makeNoise(); }

  2. class Horse implements Animal {

  3. Long weight = 1200L;

  4. public void makeNoise() { System.out.println(quot;whinnyquot;); } 7. }

  1. public class Icelandic extends Horse {

  2. public void makeNoise() { System.out.println(quot;vinnyquot;); }

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

  4. Icelandic i1 = new Icelandic();

  5. Icelandic i2 = new Icelandic();

  6. Icelandic i3 = new Icelandic(); 14. i3 = i1; i1 = i2; i2 = null; i3 = i1;

15. }

16. }

When line 15 is reached, how many objects are eligible for the garbage collector?

  1. 0

  2. 1

  3. 2

  4. 3

  5. 4

  6. 6

Answer: E

Question No: 25 – (Topic 1)

Click the Exhibit button. Given the fully-qualified class names: com.foo.bar.Dog com.foo.bar.blatz.Book com.bar.Car com.bar.blatz.Sun Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM?

Ensurepass 2018 PDF and VCE

  1. Jar A

  2. Jar B

  3. Jar C

  4. Jar D

  5. Jar E

    Answer: A

    Question No: 26 – (Topic 1)

    Given classes defined in two different files:

    1. package util;

    2. public class BitUtils {

    3. private static void process(byte[] b) {} 4. }

1. package app; 2

. public class SomeApp {

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

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

  3. // insert code here 6. }

    7. }

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

    1. process(bytes);

    2. BitUtils.process(bytes);

    3. app.BitUtils.process(bytes);

    4. util.BitUtils.process(bytes);

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

    6. SomeApp cannot use the process method in BitUtils.

Answer: F

Question No: 27 – (Topic 1)

Given:

  1. public class ItemTest {

  2. private final int id;

  3. public ItemTest(int id) { this.id = id; }

  4. public void updateId(int newId) { id = newId; } 15.

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

  2. ItemTest fa = new ItemTest(42);

  3. fa.updateId(69);

  4. System.out.println(fa.id);

20. }

21. }

What is the result?

  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. The attribute id in the ItemTest object remains unchanged.

  4. The attribute id in the ItemTest object is modified to the new value.

  5. A new ItemTest object is created with the preferred value in the id attribute.

Answer: A

Question No: 28 – (Topic 1)

Given:

  1. public class Pass {

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

  3. int x = 5;

  4. Pass p = new Pass();

  5. p.doStuff(x);

  6. System.out.print(quot; main x = quot; x);

19. } 20.

  1. void doStuff(int x) {

  2. System.out.print(quot; doStuff x = quot; x );

23. }

24. }

What is the result?

  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. doStuff x = 6 main x = 6

  4. doStuff x = 5 main x = 5

  5. doStuff x = 5 main x = 6

  6. doStuff x = 6 main x = 5

    Answer: D

    Question No: 29 – (Topic 1)

    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?

      1. Line 5

      2. Line 6

      3. Line 7

      4. Line 8

      5. Line 9

      6. Line 10

Answer: D

Question No: 30 – (Topic 1)

Given:

  1. public static void test(String str) {

  2. int check = 4;

  3. if (check = str.length()) {

  4. System.out.print(str.charAt(check -= 1) quot;, quot;);

  5. } else {

  6. System.out.print(str.charAt(0) quot;, quot;);

17. }

18. } and the invocation:

  1. test(quot;fourquot;);

  2. test(quot;teequot;);

  3. test(quot;toquot;); What is the result?

  1. r, t, t,

  2. r, e, o,

  3. Compilation fails.

  4. An exception is thrown at runtime.

    Answer: C

    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

Your email address will not be published. Required fields are marked *

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