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

Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-852
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-852.html

Java Standard Edition 6 Programmer Certified Professional Upgrade Exam

Question No: 21

Given:

11. public class Yikes { 12.

  1. public static void go(Long n) {System.out.print(quot;Long quot;);}

  2. public static void go(Short n) {System.out.print(quot;Short quot;);}

  3. public static void go(int n) {System.out.print(quot;int quot;);}

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

  5. short y = 6;

  6. long z = 7;

  7. go(y);

20. go(z); 21. }

22. }

What is the result?

  1. int Long

  2. Short Long

  3. Compilation fails.

  4. An exception is thrown at runtime.

Answer: A

Question No: 22

Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console? (Choose two.)

  1. String s = c.readLine();

  2. char[] c = c.readLine();

  3. String s = c.readConsole();

  4. char[] c = c.readConsole();

  5. String s = c.readLine(quot;%squot;, quot;name quot;);

  6. char[] c = c.readLine(quot;%squot;, quot;name quot;);

Answer: A,E

Question No: 23

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

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

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

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

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

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

    /foo/myLib.jar/Paper Book.java.

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

    /foo/myLib.jar Book.java

  7. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac – classpath /foo/myLib.jar Book.java

Answer: B,D,G

Question No: 24

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: 25

Given:

  1. public class Yippee {

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

  3. for(int x = 1; x lt; args.length; x ) {

  4. System.out.print(args[x] quot; quot;);

19. }

20. }

21. }

and two separate command line invocations: java Yippee

java Yippee 1 2 3 4 What is the result?

  1. No output is produced. 1 2 3

  2. No output is produced. 2 3 4

  3. No output is produced. 1 2 3 4

  4. An exception is thrown at runtime. 1 2 3

  5. An exception is thrown at runtime. 2 3 4

  6. An exception is thrown at runtime. 1 2 3 4

Answer: B

Question No: 26

Given:

  1. public class Commander {

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

  3. String myProp = /* insert code here */

  4. System.out.println(myProp);

15. }

16. }

and the command line:

java -Dprop.custom=gobstopper Commander

Which two, placed on line 13, will produce the output gobstopper? (Choose two.)

  1. System.load(quot;prop.customquot;);

  2. System.getenv(quot;prop.customquot;);

  3. System.property(quot;prop.customquot;);

  4. System.getProperty(quot;prop.customquot;);

  5. System.getProperties().getProperty(quot;prop.customquot;);

    Answer: D,E

    Question No: 27

    Given:

    1. public class Donkey {

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

    3. boolean assertsOn = false;

    4. assert (assertsOn) : assertsOn = true;

    5. if(assertsOn) {

    6. System.out.println(quot;assert is onquot;); 7. }

      8. }

      9. }

      If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?

      1. no output

      2. no output assert is on

      3. assert is on

      4. no output

        An AssertionError is thrown.

      5. assert is on

An AssertionError is thrown.

Answer: D

Question No: 28

Given:

  1. interface Foo {}

  2. class Alpha implements Foo {}

  3. class Beta extends Alpha {}

  4. class Delta extends Beta {

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

  6. Beta x = new Beta();

  7. // insert code here

17. }

18. }

Which code, inserted at line 16, will cause a java.lang.ClassCastException?

  1. Alpha a = x;

  2. Foo f = (Delta)x;

  3. Foo f = (Alpha)x;

  4. Beta b = (Beta)(Alpha)x;

Answer: B

Question No: 29

Given:

  1. public void testIfA() {

  2. if (testIfB(quot;Truequot;)) {

  3. System.out.println(quot;Truequot;);

  4. } else {

  5. System.out.println(quot;Not truequot;);

16. }

17. }

  1. public Boolean testIfB(String str) {

  2. return Boolean.valueOf(str);

20. }

What is the result when method testIfA is invoked?

  1. True

  2. Not true

  3. An exception is thrown at runtime.

  4. Compilation fails because of an error at line 12.

  5. Compilation fails because of an error at line 19.

Answer: A

Question No: 30

Which can appropriately be thrown by a programmer using Java SE technology to create a desktop application?

  1. ClassCastException

  2. NullPointerException

  3. NoClassDefFoundError

  4. NumberFormatException

  5. ArrayIndexOutOfBoundsException

    Answer: D

    100% Ensurepass Free Download!
    Download Free Demo:1z0-852 Demo PDF
    100% Ensurepass Free Guaranteed!
    1z0-852 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.