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.
-
public static void go(Long n) {System.out.print(quot;Long quot;);}
-
public static void go(Short n) {System.out.print(quot;Short quot;);}
-
public static void go(int n) {System.out.print(quot;int quot;);}
-
public static void main(String [] args) {
-
short y = 6;
-
long z = 7;
-
go(y);
20. go(z); 21. }
22. }
What is the result?
-
int Long
-
Short Long
-
Compilation fails.
-
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.)
-
String s = c.readLine();
-
char[] c = c.readLine();
-
String s = c.readConsole();
-
char[] c = c.readConsole();
-
String s = c.readLine(quot;%squot;, quot;name quot;);
-
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.)
-
The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.
-
The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..
-
The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar/Paper.class.
-
The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes /foo/myLib.jar.
-
The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -cp
/foo/myLib.jar/Paper Book.java.
-
The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d
/foo/myLib.jar Book.java
-
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?
-
/test/Chess.class
-
/home/bob/Chess.class
-
/test/games/Chess.class
-
/usr/lib/games/Chess.class
-
/home/bob/games/Chess.class
-
inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
-
inside jarfile /home/bob/downloads/Games.jar (with a correct manifest)
Answer: C
Question No: 25
Given:
-
public class Yippee {
-
public static void main(String [] args) {
-
for(int x = 1; x lt; args.length; x ) {
-
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?
-
No output is produced. 1 2 3
-
No output is produced. 2 3 4
-
No output is produced. 1 2 3 4
-
An exception is thrown at runtime. 1 2 3
-
An exception is thrown at runtime. 2 3 4
-
An exception is thrown at runtime. 1 2 3 4
Answer: B
Question No: 26
Given:
-
public class Commander {
-
public static void main(String[] args) {
-
String myProp = /* insert code here */
-
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.)
-
System.load(quot;prop.customquot;);
-
System.getenv(quot;prop.customquot;);
-
System.property(quot;prop.customquot;);
-
System.getProperty(quot;prop.customquot;);
-
System.getProperties().getProperty(quot;prop.customquot;);
Answer: D,E
Question No: 27
Given:
-
public class Donkey {
-
public static void main(String[] args) {
-
boolean assertsOn = false;
-
assert (assertsOn) : assertsOn = true;
-
if(assertsOn) {
-
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?
-
no output
-
no output assert is on
-
assert is on
-
no output
An AssertionError is thrown.
-
assert is on
-
-
An AssertionError is thrown.
Answer: D
Question No: 28
Given:
-
interface Foo {}
-
class Alpha implements Foo {}
-
class Beta extends Alpha {}
-
class Delta extends Beta {
-
public static void main( String[] args ) {
-
Beta x = new Beta();
-
// insert code here
17. }
18. }
Which code, inserted at line 16, will cause a java.lang.ClassCastException?
-
Alpha a = x;
-
Foo f = (Delta)x;
-
Foo f = (Alpha)x;
-
Beta b = (Beta)(Alpha)x;
Answer: B
Question No: 29
Given:
-
public void testIfA() {
-
if (testIfB(quot;Truequot;)) {
-
System.out.println(quot;Truequot;);
-
} else {
-
System.out.println(quot;Not truequot;);
16. }
17. }
-
public Boolean testIfB(String str) {
-
return Boolean.valueOf(str);
20. }
What is the result when method testIfA is invoked?
-
True
-
Not true
-
An exception is thrown at runtime.
-
Compilation fails because of an error at line 12.
-
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?
-
ClassCastException
-
NullPointerException
-
NoClassDefFoundError
-
NumberFormatException
-
ArrayIndexOutOfBoundsException
Answer: D
100% Ensurepass Free Download!
–Download Free Demo:1z0-852 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-852 DumpsEnsurePass 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 HOT CATEGORY!HOT EXAM!100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF